This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c/77280] program using sizeof(array) fails after adding a statement with sizeof(array)


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77280

Jonathan Wakely <redi at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|---                         |INVALID

--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Comment on attachment 39467
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=39467
source

Pr has an undefined value the first time through the loop.

--- Comment #3 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Comment on attachment 39467
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=39467
source

Pr has an undefined value the first time through the loop.

--- Comment #4 from Jonathan Wakely <redi at gcc dot gnu.org> ---
(In reply to Jorg Kewisch from comment #0)
> The attached code works correctly when 1) the two lines 
>  45       unsigned int lx = sizeof(t);
>  46       printf("lx %d\n", lx);
> are removed or 2) the line 
>  44        int a=0;
> is added.

This kind of behaviour almost always means you have a bug that is sensitive to
the exact layout of variables on the stack (as is the case here, where you are
using the garbage value of pr). It's very unlikely to be a bug in the compiler.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]