[Bug tree-optimization/106457] array_at_struct_end_p returns TRUE for a two-dimension array which is not inside any structure
qinzhao at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Tue Aug 9 14:16:35 GMT 2022
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106457
--- Comment #9 from qinzhao at gcc dot gnu.org ---
one more testing case failed with the current array_at_struct_end_p
is:gcc/testsuite/gcc.dg/torture/pr50067-2.c:
1 /* { dg-do run } */
2
3 /* Make sure data-dependence analysis does not compute a bogus
4 distance vector for the different sized accesses. */
5
6 extern int memcmp(const void *, const void *, __SIZE_TYPE__);
7 extern void abort (void);
8 short a[32] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,
17, 18, 19, 20, 21 , 22, 23, 24, 25, 26, 27, 28, 29, 30, 31 };
9 short b[32] = { 4, 0, 5, 0, 6, 0, 7, 0, 8, 0, };
10 int main()
11 {
12 #if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
13 int i;
14 if (sizeof (short) == 2)
15 {
16 for (i = 0; i < 32; ++i)
17 {
18 a[i] = (*((char(*)[32])&a[0]))[i+8];
19 }
20 if (memcmp (&a, &b, sizeof (a)) != 0)
21 abort ();
22 }
23 #endif
24 return 0;
25 }
In the above, at line 18: (*((char(*)[32])&a[0]))[i+8] was identified as TRUE:
Breakpoint 1, array_at_struct_end_p (ref=0xfffff57a2b18) at
../../latest_gcc/gcc/tree.cc:12690
12690 if (TREE_CODE (ref) == ARRAY_REF
(gdb) call debug_tree(ref)
<array_ref 0xfffff57a2b18
type <integer_type 0xfffff57d03f0 char public unsigned QI
size <integer_cst 0xfffff56c0f00 constant 8>
unit-size <integer_cst 0xfffff56c0f18 constant 1>
align:8 warn_if_not_align:0 symtab:0 alias-set -1 canonical-type
0xfffff57d03f0 precision:8 min <integer_cst 0xfffff56c0f60 0> max <integer_cst
0xfffff56c0f48 255>
pointer_to_this <pointer_type 0xfffff57d40f8>>
arg:0 <mem_ref 0xfffff59fe3d0
type <array_type 0xfffff59950b8 type <integer_type 0xfffff57d03f0 char>
BLK
size <integer_cst 0xfffff56c1170 constant 256>
unit-size <integer_cst 0xfffff56c1260 constant 32>
align:8 warn_if_not_align:0 symtab:0 alias-set 0 canonical-type
0xfffff59950b8 domain <integer_type 0xfffff5994b78>
pointer_to_this <pointer_type 0xfffff5995160>>
arg:0 <addr_expr 0xfffff56dbb80 type <pointer_type 0xfffff5995208>
constant arg:0 <var_decl 0xfffff5770ea0 a>>
arg:1 <integer_cst 0xfffff56c7c20 constant 0>
/home/opc/Work/GCC/latest_gcc/gcc/testsuite/gcc.dg/torture/pr50067-2.c:18:12
start:
/home/opc/Work/GCC/latest_gcc/gcc/testsuite/gcc.dg/torture/pr50067-2.c:18:11
finish:
/home/opc/Work/GCC/latest_gcc/gcc/testsuite/gcc.dg/torture/pr50067-2.c:18:33>
arg:1 <ssa_name 0xfffff5761320
type <integer_type 0xfffff57d05e8 int sizes-gimplified public SI
size <integer_cst 0xfffff56c1050 constant 32>
unit-size <integer_cst 0xfffff56c1068 constant 4>
align:32 warn_if_not_align:0 symtab:0 alias-set -1 canonical-type
0xfffff57d05e8 precision:32 min <integer_cst 0xfffff56c1008 -2147483648> max
<integer_cst 0xfffff56c1020 2147483647>
pointer_to_this <pointer_type 0xfffff57d1a40>>
visited
def_stmt _1 = i_5 + 8;
version:1>
/home/opc/Work/GCC/latest_gcc/gcc/testsuite/gcc.dg/torture/pr50067-2.c:18:34
start:
/home/opc/Work/GCC/latest_gcc/gcc/testsuite/gcc.dg/torture/pr50067-2.c:18:11
finish:
/home/opc/Work/GCC/latest_gcc/gcc/testsuite/gcc.dg/torture/pr50067-2.c:18:38>
...
(gdb) n
12801 return true;
More information about the Gcc-bugs
mailing list