[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: |
Dmitrii Pasechnik |
Subject: |
Re: [bug #60798] Make does not compile with GCC 11.1.0 |
Date: |
Sat, 19 Jun 2021 16:40:08 +0100 |
On Sat, Jun 19, 2021 at 11:10:14AM -0400, Dmitry Goncharov wrote:
> On Sat, Jun 19, 2021 at 10:31 AM Dmitrii Pasechnik
> <dima.pasechnik@cs.ox.ac.uk> wrote:
> > It's undefined behaviour in C to point to such a location, isn't it?
> > Is this hack really needed?
>
> There is no hack. It is pointer arithmetic in c. p[-1] is the same as *(p-1).
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]);
^ ~~
- [bug #60798] Make does not compile with GCC 11.1.0, (continued)
- [bug #60798] Make does not compile with GCC 11.1.0, Paul D. Smith, 2021/06/18
- Re: [bug #60798] Make does not compile with GCC 11.1.0, Dmitrii Pasechnik, 2021/06/19
- Re: [bug #60798] Make does not compile with GCC 11.1.0, Paul Smith, 2021/06/19
- Re: [bug #60798] Make does not compile with GCC 11.1.0, Eli Zaretskii, 2021/06/19
- Re: [bug #60798] Make does not compile with GCC 11.1.0, Dmitrii Pasechnik, 2021/06/19
- Re: [bug #60798] Make does not compile with GCC 11.1.0, Paul Smith, 2021/06/19
- Re: [bug #60798] Make does not compile with GCC 11.1.0, Andreas Schwab, 2021/06/21
- Re: [bug #60798] Make does not compile with GCC 11.1.0, David A. Wheeler, 2021/06/21
- Re: [bug #60798] Make does not compile with GCC 11.1.0, RANDRIANAINA Georges Aaron, 2021/06/21
- Re: [bug #60798] Make does not compile with GCC 11.1.0, Dmitry Goncharov, 2021/06/19
- Re: [bug #60798] Make does not compile with GCC 11.1.0,
Dmitrii Pasechnik <=
- Re: [bug #60798] Make does not compile with GCC 11.1.0, Eli Zaretskii, 2021/06/19