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: "pinskia at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Sat, 26 May 2012 23:47:56 +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 #3 from Andrew Pinski <pinskia at gcc dot gnu.org> 2012-05-26 23:47:56 UTC ---
(gdb) p debug_tree(t)
<indirect_ref 0x7ffff6e4c500
type <integer_type 0x7ffff6e6e000 int readonly SI
size <integer_cst 0x7ffff6d4d080 constant 32>
unit size <integer_cst 0x7ffff6d4d0a0 constant 4>
align 32 symtab 0 alias set -1 canonical type 0x7ffff6e6e000 precision
32 min <integer_cst 0x7ffff6d4d020 -2147483648> max <integer_cst 0x7ffff6d4d040
2147483647>
pointer_to_this <pointer_type 0x7ffff6e6e0a8>>
readonly
arg 0 <var_decl 0x7ffff6d3e280 x
type <pointer_type 0x7ffff6e6e0a8 type <integer_type 0x7ffff6e6e000
int>
unsigned DI
size <integer_cst 0x7ffff6d31d40 constant 64>
unit size <integer_cst 0x7ffff6d31d60 constant 8>
align 64 symtab 0 alias set -1 canonical type 0x7ffff6e6e0a8>
used unsigned DI file t1.c line 6 col 13 size <integer_cst
0x7ffff6d31d40 64> unit size <integer_cst 0x7ffff6d31d60 8>
align 64 context <function_decl 0x7ffff6e52200 broken> initial
<nop_expr 0x7ffff6e4c4b0>>
t1.c:7:11>
The indirect reference is marked as readonly.
2663 static bool
2664 tree_invariant_p_1 (tree t)
2665 {
2666 tree op;
2667
2668 if (TREE_CONSTANT (t)
2669 || (TREE_READONLY (t) && !TREE_SIDE_EFFECTS (t)))
2670 return true;
Is where the issue is.