broken code only when optimized "-O2"

Segher Boessenkool segher@kernel.crashing.org
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
> ><gcc-help@gcc.gnu.org> 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.  6.3.2.1/2:
  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
  conversion.

There is no dereferencing.


Segher


More information about the Gcc-help mailing list