This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/53424] dynamic array expressions get wrong sizeof() if pointers to const are involved and the pointers are changed (const is misapplied to the whole expression)
- From: "gccbug at shaggy dot cc" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Sun, 20 May 2012 05:31:02 +0000
- Subject: [Bug c/53424] dynamic array expressions get wrong sizeof() if pointers to const are involved and the pointers are changed (const is misapplied to the whole expression)
- Auto-submitted: auto-generated
- References: <bug-53424-4@http.gcc.gnu.org/bugzilla/>
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53424
--- Comment #1 from Frank Barrus <gccbug at shaggy dot cc> 2012-05-20 05:31:02 UTC ---
Of particular attention, look at the example function "negativesizeof2".
It's not just the sizeof() function returning the incorrect size. In this
case, the pointer change retroactively changed the size of a struct already
declared, and which a variable was instantiated from. And it didn't just
change it for sizeof(). Pointer arithmetic is actually wrong, and the size is
negative. So a step forward actually goes backwards!