bug-make
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [bug #60798] Make does not compile with GCC 11.1.0


From: Eli Zaretskii
Subject: Re: [bug #60798] Make does not compile with GCC 11.1.0
Date: Sat, 19 Jun 2021 18:46:43 +0300

> Date: Sat, 19 Jun 2021 16:40:08 +0100
> From: Dmitrii Pasechnik <dima.pasechnik@cs.ox.ac.uk>
> Cc: boris@kolpackov.net, bug-make <bug-make@gnu.org>
> 
> Compiler does not guarantee you that doing something with p[-1]
> is not going to end in a segfault. It's hack, as it just happens to work, but 
> YMMV.
> 
> E.g. clang 10, or Apple's clang 12, will print a warning:
> 
> warning: array index -1 is before the beginning of the array [-Warray-bounds]
> printf("%d", p[-1]);
>              ^ ~~

That warning is a bug in the compiler.  p is not an array, it's a
pointer into an array, and it doesn't have to (and in this case
actually does not) point to the first element of that array.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]