broken code only when optimized "-O2"

Segher Boessenkool
Tue Dec 21 16:39:50 GMT 2021

On Tue, Dec 21, 2021 at 05:13:08PM +0100, Adrian Moreno via Gcc-help wrote:
> On 12/21/21 17:05, Stefan Ring wrote:
> >On Tue, Dec 21, 2021 at 4:40 PM Adrian Moreno via Gcc-help
> ><> wrote:
> >>
> >>I'd really appreciate any hint or idea to try to understand this problem.
> >
> >I guess the compiler doesn't like the dereferencing of uninitialized
> >pointers (in the sizeof expressions). I am not 100% sure that this
> >counts as dereferencing, but I would assume so. Because of this the
> >compiler will be free to behave however it likes to.
> I agree that doesn't look good. Replacing them by sizeof (struct ___) 
> expressions does not change the behavior though.

As required by C.
  Except when it is the operand of the sizeof operator, [...], an lvalue
  that does not have array type is converted to the value stored in the
  designated object (and is no longer an lvalue); this is called lvalue

There is no dereferencing.


More information about the Gcc-help mailing list