ripOLE
ripOLE copied to clipboard
gcc/clang drop warning about comparison between pointer and zero character constant (pldstr.c:300:30)
Hi there! I'm trying to compile ripOLE under Ubuntu 20.04.1 LTS. I have no problems with -Werror turned off, but it might be worth taking a look at that particular comparison:
GCC 9.3.0:
gcc -Wall -g -O2 -I. -Werror -c pldstr.c
pldstr.c: In function ‘PLD_strtok’:
pldstr.c:300:30: error: comparison between pointer and zero character constant [-Werror=pointer-compare]
300 | if ((st->start)&&(st->start != '\0'))
| ^~
pldstr.c:300:20: note: did you mean to dereference the pointer?
300 | if ((st->start)&&(st->start != '\0'))
| ^
cc1: all warnings being treated as errors
make: *** [Makefile:7: pldstr.o] Error 1
Clang 10.0.0:
clang -Wall -g -O2 -I. -Werror -c pldstr.c
pldstr.c:300:33: error: comparing a pointer to a null character constant; did you mean to compare to NULL? [-Werror,-Wpointer-compare]
if ((st->start)&&(st->start != '\0'))
^~~~
(void *)0
1 error generated.
make: *** [Makefile:7: pldstr.o] Error 1
Of course, you can always rewrite line 300 as:
if ((st->start)&&(*st->start != '\0'))
which is semantically more correct (I think... it's been many years since I last did some 'serious' work on C...), and similar to the code on line 286... but maybe it's not what's intended?