Warning for test on clang 3.8
Closed this issue · 2 comments
brieflz/test/test_brieflz.c:410:1889: error: self-comparison always evaluates to true [-Werror,-Wtautological-compare]
FWIW, -Wtautological-compare
is on by default (it is triggered without even -Wextra
or -Wall
, though of course it's just a warning without -Werror
).
Unfortunately, test_brieflz.c:410 is GREATEST_MAIN_DEFS()
, so this may be tricky to fix…
You could just use diagnostic pragmas to ignore the warning, though you would have to check for clang >= 3.8 to avoid triggering a new warning in older compilers. Also, I believe Apple's compiler advertises a different (higher) version number, and I'm not sure how to distinguish between normal clang and Apple clang… usually the right way to work around this is to use one of the __has_X
macros, but I don't think there is one for warning flags…
The easiest thing to do would probably be to add -Wno-tautological-compare
to the compiler flags. I guess something like (untested):
check_c_compiler_flag("-Wtautological-compare" CFLAG_Wtautological_compare)
if(CFLAG_Wtautological_compare)
set_property(TARGET test_brieflz APPEND_STRING PROPERTY COMPILE_FLAGS ";-Wno-tautological-compare")
endif()
Thanks. I opened an issue on greatest for this, lets see if it can be fixed upstream.
I know it's already been fixed upstream, but it turns out I was wrong about there being a way to detect if a warning flag is supported on clang; there is a __has_warning macro.