-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
TEMPLATE_TEST_CASE triggers -Wstring-plus-int #1806
Comments
Can't reproduce with Clang
|
I cannot reproduce on Ubuntu 19.04 with
Then compilation (of the same file as you did):
The |
Right, it seems that Clang actually masks itself for MSVC well enough to get the path for MSVC's old preprocessor, which contains this #define INTERNAL_CATCH_STRINGIZE_WITHOUT_PARENS(param) (INTERNAL_CATCH_STRINGIZE(INTERNAL_CATCH_REMOVE_PARENS(param)) + 1) because the preprocessor just prepends a space when expanding the argument with |
Describe the bug
Clang and clang-tidy warns with
-Wstring-plus-int
wheneverTEMPLATE_TEST_CASE
is used. It triggers with any template argument (not justint
).The warning message:
Suggested fix:
Expected behavior
TEMPLATE_TEST_CASE does not generate
-Wstring-plus-int
warning.Reproduction steps
Platform information:
Additional context
I cannot pinpoint the exact location in the code that triggers this because the warning stack exceeds its limits for macro expansions but I reckon people familiar with the Catch2 internals would have a good idea what might be the issue that triggers this.
It will be something like
"mystring" + 1
or somesuch. And the fix is to advance address of the string, not the string itself, e.g.&"mystring"[1]
.See live demo: https://godbolt.org/z/TkaTSV
The text was updated successfully, but these errors were encountered: