This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/77280] program using sizeof(array) fails after adding a statement with sizeof(array)
- From: "redi at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Wed, 17 Aug 2016 14:04:01 +0000
- Subject: [Bug c/77280] program using sizeof(array) fails after adding a statement with sizeof(array)
- Authentication-results: sourceware.org; auth=none
- Auto-submitted: auto-generated
- References: <bug-77280-4@http.gcc.gnu.org/bugzilla/>
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.