[Bug 224669] [exp-run] Against projects/clang600-import branch

bugzilla-noreply at freebsd.org bugzilla-noreply at freebsd.org
Thu Jan 4 10:01:34 UTC 2018


https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=224669

--- Comment #11 from Dimitry Andric <dim at FreeBSD.org> ---
(In reply to Jan Beich from comment #10)
> Notice how "comparison between pointer and integer" issue is similar to
> "ordered comparison between pointer and integer". Clang prefers to not warn
> about possible bugs unless it's C++ or C++11.
> 
> $ cat a.c
> int main()
> {
>   const char *value[] = { "", "bar" };
>   if (value[0] == '\0')
>     return 1;
>   return 0;
> }
> $ cc a.c
> $ c++ -std=gnu++98 -x c++ a.c
> $ gcc7 a.c
> a.c: In function 'main':
> a.c:4:16: warning: comparison between pointer and zero character constant
> [-Wpointer-compare]
>    if (value[0] == '\0')
>                 ^~
> a.c:4:7: note: did you mean to dereference the pointer?
>    if (value[0] == '\0')
>        ^
> $ g++7 -std=gnu++98 -x c++ a.c
> a.c: In function 'int main()':
> a.c:4:19: warning: comparison between pointer and zero character constant
> [-Wpointer-compare]
>    if (value[0] == '\0')
>                    ^~~~
> a.c:4:19: note: did you mean to dereference the pointer?

Hmm I think that is actually a bit weird.  I would have expected this warning
to always fire, but apparently not.  I have not yet been able to find where
this exactly changed between clang 5 and 6.

In any case, these warnings point to real programming errors, so ideally they
should be properly patched.  As a workaround USE_CXXSTD=gnu++98 is fine with
me, though gcc still warns in that case.

-- 
You are receiving this mail because:
You are on the CC list for the bug.


More information about the freebsd-ports-bugs mailing list