Willy,

Am 23.01.20 um 10:56 schrieb Willy Tarreau:
>> I've using clang during the testing, and apparently -Wextra doesn't enable
>> it on clang (I'm using v9.0), only -pedantic helps:
>>
>> clang -Wall -Wextra -Wpedantic test.c
>>
>> test.c:6:12: warning: ordered comparison between pointer and zero ('char *'
>> and 'int') is an extension [-Wpedantic]
> 
> Ah that's interesting, because from a semantic perspective there is no
> reason to compare an int and a pointer, given that an int is a distance
> between two pointers (divided by the element's size), so being able to

Not to disgress too much, but isn't `ptrdiff_t` from `stddef.h` the
distance between two pointers? :-)

Of course comparing a pointer to a `ptrdiff_t` still doesn't make sense.

> do that implies that it is possible to add two pointers, which makes no
> sense:
> 
>     let i := p1 - p2
>     for (i < p3) to be true, this would mean:
>       p1 - p2 < p3
>       p1 < p2 + p3    :-)
> 
> And going further we might even multiply pointers to create areas or
> volumes maybe! Compilers will never cease to amaze me! At least this
> explains the difference between what you saw and what I saw.
> 

Best regards
Tim Düsterhus

Reply via email to