[Bug bootstrap/101374] [12 Regression] bootstrap failure varpool.c:490:19: error: array subscript 'varpool_node[0]' is partly outside array bounds of 'varpool_node [0]' [-Werror=array-bounds]

2021-07-16 Thread abidh at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101374

Hafiz Abid qadeer  changed:

   What|Removed |Added

 CC||abidh at gcc dot gnu.org

--- Comment #16 from Hafiz Abid qadeer  ---
Similar problem in libgomp and it is still broken. I was building for x86_64
with amdgcn offloading.

/scratch/cfi/x86_64-linux-gnu-amdgcn/obj/accel-gcc-mainline/./gcc/xgcc
-B/scratch/cfi/x86_64-linux-gnu-amdgcn/obj/accel-gcc-mainline/./gcc/
-B/scratch/cfi/x86_64-linux-gnu-amdgcn/install/amdgcn-amdhsa/bin/
-B/scratch/cfi/x86_64-linux-gnu-amdgcn/install/amdgcn-amdhsa/lib/ -isystem
/scratch/cfi/x86_64-linux-gnu-amdgcn/install/amdgcn-amdhsa/include -isystem
/scratch/cfi/x86_64-linux-gnu-amdgcn/install/amdgcn-amdhsa/sys-include   
-DHAVE_CONFIG_H -I.
-I/scratch/cfi/x86_64-linux-gnu-amdgcn/src/gcc-mainline/libgomp 
-I/scratch/cfi/x86_64-linux-gnu-amdgcn/src/gcc-mainline/libgomp/config/gcn
-I/scratch/cfi/x86_64-linux-gnu-amdgcn/src/gcc-mainline/libgomp/config/accel
-I/scratch/cfi/x86_64-linux-gnu-amdgcn/src/gcc-mainline/libgomp
-I/scratch/cfi/x86_64-linux-gnu-amdgcn/src/gcc-mainline/libgomp/../include 
-Wall -Werror  -g -O2 -MT barrier.lo -MD -MP -MF .deps/barrier.Tpo -c -o
barrier.lo
/scratch/cfi/x86_64-linux-gnu-amdgcn/src/gcc-mainline/libgomp/barrier.c
In file included from
/scratch/cfi/x86_64-linux-gnu-amdgcn/src/gcc-mainline/libgomp/barrier.c:28:
In function 'gcn_thrs',
inlined from 'gomp_thread' at
/scratch/cfi/x86_64-linux-gnu-amdgcn/src/gcc-mainline/libgomp/libgomp.h:803:10,
inlined from 'GOMP_barrier' at
/scratch/cfi/x86_64-linux-gnu-amdgcn/src/gcc-mainline/libgomp/barrier.c:34:29:
/scratch/cfi/x86_64-linux-gnu-amdgcn/src/gcc-mainline/libgomp/libgomp.h:792:10:
error: array subscript 0 is outside array bounds of '__lds struct gomp_thread *
__lds[0]' [-Werror=array-bounds]
  792 |   return *thrs;
  |  ^
In function 'gcn_thrs',
inlined from 'gomp_thread' at
/scratch/cfi/x86_64-linux-gnu-amdgcn/src/gcc-mainline/libgomp/libgomp.h:803:10,
inlined from 'GOMP_barrier_cancel' at
/scratch/cfi/x86_64-linux-gnu-amdgcn/src/gcc-mainline/libgomp/barrier.c:47:29:
/scratch/cfi/x86_64-linux-gnu-amdgcn/src/gcc-mainline/libgomp/libgomp.h:792:10:
error: array subscript 0 is outside array bounds of '__lds struct gomp_thread *
__lds[0]' [-Werror=array-bounds]
  792 |   return *thrs;
  |  ^

[Bug bootstrap/101374] [12 Regression] bootstrap failure varpool.c:490:19: error: array subscript 'varpool_node[0]' is partly outside array bounds of 'varpool_node [0]' [-Werror=array-bounds]

2021-07-13 Thread msebor at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101374

Martin Sebor  changed:

   What|Removed |Added

 Resolution|--- |FIXED
 Status|ASSIGNED|RESOLVED

--- Comment #15 from Martin Sebor  ---
Fixed by r12-2171; Go fixed by r12-2234.

[Bug bootstrap/101374] [12 Regression] bootstrap failure varpool.c:490:19: error: array subscript 'varpool_node[0]' is partly outside array bounds of 'varpool_node [0]' [-Werror=array-bounds]

2021-07-09 Thread cvs-commit at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101374

--- Comment #14 from CVS Commits  ---
The master branch has been updated by Ian Lance Taylor :

https://gcc.gnu.org/g:1798cac7a8b3331a277da1f106752ce0a34f8937

commit r12-2234-g1798cac7a8b3331a277da1f106752ce0a34f8937
Author: Ian Lance Taylor 
Date:   Thu Jul 8 19:25:55 2021 -0700

runtime: remove direct assignments to memory locations

PR bootstrap/101374
They cause a warning with the updated GCC -Warray-bounds option.
Replace them with calls to abort, which for our purposes is fine.

Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/333409

[Bug bootstrap/101374] [12 Regression] bootstrap failure varpool.c:490:19: error: array subscript 'varpool_node[0]' is partly outside array bounds of 'varpool_node [0]' [-Werror=array-bounds]

2021-07-08 Thread msebor at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101374

--- Comment #13 from Martin Sebor  ---
Thanks for the confirmation!

[Bug bootstrap/101374] [12 Regression] bootstrap failure varpool.c:490:19: error: array subscript 'varpool_node[0]' is partly outside array bounds of 'varpool_node [0]' [-Werror=array-bounds]

2021-07-08 Thread bergner at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101374

--- Comment #12 from Peter Bergner  ---
(In reply to Martin Sebor from comment #11)
> r12-2171 unblocks bootstrap on x86_64.

My bootstrap on powerpc64le-linux completes now too.

[Bug bootstrap/101374] [12 Regression] bootstrap failure varpool.c:490:19: error: array subscript 'varpool_node[0]' is partly outside array bounds of 'varpool_node [0]' [-Werror=array-bounds]

2021-07-08 Thread msebor at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101374

Martin Sebor  changed:

   What|Removed |Added

   Keywords||patch

--- Comment #11 from Martin Sebor  ---
r12-2171 unblocks bootstrap on x86_64.  I'll leave this open in case there's
still more fallout.

Go currently doesn't bootstrap due to a valid -Warray-bounds triggered also by
r12-2132.  I sent the patch below to Ian:
https://gcc.gnu.org/pipermail/gcc-patches/2021-July/574752.html

[Bug bootstrap/101374] [12 Regression] bootstrap failure varpool.c:490:19: error: array subscript 'varpool_node[0]' is partly outside array bounds of 'varpool_node [0]' [-Werror=array-bounds]

2021-07-08 Thread cvs-commit at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101374

--- Comment #10 from CVS Commits  ---
The master branch has been updated by Martin Sebor :

https://gcc.gnu.org/g:9bf9f27ac6db4823628c435da9b242fd82bf8d68

commit r12-2171-g9bf9f27ac6db4823628c435da9b242fd82bf8d68
Author: Martin Sebor 
Date:   Thu Jul 8 11:34:27 2021 -0600

Use Object Size Type zero for -Warray-bounds [PR101374].

Resolves:
PR bootstrap/101374 - -Warray-bounds accessing a member subobject as
derived

gcc/cp/ChangeLog:
PR bootstrap/101374
* module.cc (module_state::read_macro_maps): Temporarily disable
-Warray-bounds.
(module_state::install_macros): Same.

gcc/ChangeLog:
PR bootstrap/101374
* gimple-array-bounds.cc (array_bounds_checker::check_mem_ref):
Use Object Size Type 0 instead of 1.

gcc/testsuite/ChangeLog:
PR bootstrap/101374
* c-c++-common/Warray-bounds-3.c: Xfail assertion.
* c-c++-common/Warray-bounds-4.c: Same.

[Bug bootstrap/101374] [12 Regression] bootstrap failure varpool.c:490:19: error: array subscript 'varpool_node[0]' is partly outside array bounds of 'varpool_node [0]' [-Werror=array-bounds]

2021-07-08 Thread msebor at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101374

--- Comment #9 from Martin Sebor  ---
For the test case the warning sees this:

int varpool_node::_ZN12varpool_node16get_availabilityEv.part.0 (struct
varpool_node * const this)
{
  ...
  struct symtab_node * _7;
  struct varpool_node * _12;
  ...
   [local count: 1073741824]:
  _7 = _1(D)->D.2395;<<< varpool_node::symtab_node subobject
  _11 = is_a (_7);
  if (_11 != 0)
goto ; [71.00%]
  else
goto ; [29.00%]

   [local count: 311385128]:

   [local count: 1073741824]:
  # _12 = PHI <_7(2), 0B(3)>  <<< _12 size is (at most) 4
  _15 = BIT_FIELD_REF <*_12, 8, 0>;   <<< -Warray-bounds

The MEM_REF *_12 accesses a varpool_node object with size 8 but _12 points to a
symtab_node subobject with size of just 4.  So the warning code works
correctly.  It triggers because the call to compute_objsize(..., 1, ...) (with
Object Size Type 1) respects subobject boundaries and so doesn't consider that
_12, or more precisely _7, points to a subobject of a larger object.  Before
r12-2132 -Warray-bounds did its own slightly more conservative computation
which was roughly equivalent to Object Size Type 0.

Calling compute_objsize(..., 0, ...) instead avoids the warning for the reduced
test case.  Let me see if it also fixes the rest of the problems.

[Bug bootstrap/101374] [12 Regression] bootstrap failure varpool.c:490:19: error: array subscript 'varpool_node[0]' is partly outside array bounds of 'varpool_node [0]' [-Werror=array-bounds]

2021-07-08 Thread msebor at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101374

Martin Sebor  changed:

   What|Removed |Added

 Status|UNCONFIRMED |ASSIGNED
 Ever confirmed|0   |1
   Assignee|unassigned at gcc dot gnu.org  |msebor at gcc dot 
gnu.org
   Last reconfirmed||2021-07-08

--- Comment #8 from Martin Sebor  ---
Thanks for the reduced test case!

[Bug bootstrap/101374] [12 Regression] bootstrap failure varpool.c:490:19: error: array subscript 'varpool_node[0]' is partly outside array bounds of 'varpool_node [0]' [-Werror=array-bounds]

2021-07-08 Thread schwab--- via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101374

Andreas Schwab  changed:

   What|Removed |Added

 CC||clyon at gcc dot gnu.org

--- Comment #7 from Andreas Schwab  ---
*** Bug 101379 has been marked as a duplicate of this bug. ***

[Bug bootstrap/101374] [12 Regression] bootstrap failure varpool.c:490:19: error: array subscript 'varpool_node[0]' is partly outside array bounds of 'varpool_node [0]' [-Werror=array-bounds]

2021-07-08 Thread schwab--- via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101374

Andreas Schwab  changed:

   What|Removed |Added

 Target|x86_64-*-*  |

--- Comment #6 from Andreas Schwab  ---
Broken everywhere.

[Bug bootstrap/101374] [12 Regression] bootstrap failure varpool.c:490:19: error: array subscript 'varpool_node[0]' is partly outside array bounds of 'varpool_node [0]' [-Werror=array-bounds]

2021-07-08 Thread schwab--- via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101374

Andreas Schwab  changed:

   What|Removed |Added

 CC||tnfchris at gcc dot gnu.org

--- Comment #5 from Andreas Schwab  ---
*** Bug 101372 has been marked as a duplicate of this bug. ***

[Bug bootstrap/101374] [12 Regression] bootstrap failure varpool.c:490:19: error: array subscript 'varpool_node[0]' is partly outside array bounds of 'varpool_node [0]' [-Werror=array-bounds]

2021-07-08 Thread rguenth at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101374

--- Comment #4 from Richard Biener  ---
Little bit less undefined - reconstructed the original symtab_node *ref
argument of get_availability.  Maybe we're confused about the upcast to
varpool_node?

template  struct reinterpret_is_a_helper {
  template  static T cast(U p) { return T(p); }
};
template  bool is_a(U);
template  T dyn_cast(U p) {
  if (is_a(p))
return reinterpret_is_a_helper::cast(p);
  return 0;
}
enum tree_node_structure_enum { TS_DECL_COMMON };
void contains_struct_check(int, tree_node_structure_enum, const char *, int,
   const char *);
enum availability { AVAIL_NOT_AVAILABLE, AVAIL_AVAILABLE };
struct symtab_node {
  symtab_node *ultimate_alias_target();
  unsigned definition : 1;
  unsigned in_other_partition : 1;
};
struct varpool_node : symtab_node {
  availability get_availability(symtab_node *);
  varpool_node *ultimate_alias_target(symtab_node *);
  unsigned : 1;
};
inline symtab_node *symtab_node::ultimate_alias_target() {
  dyn_cast(this)->get_availability(this);
  dyn_cast(this)->get_availability(this);
  return 0;
}
inline varpool_node *varpool_node::ultimate_alias_target(symtab_node *) {
  symtab_node __trans_tmp_1 = *symtab_node::ultimate_alias_target();
  varpool_node *n = dyn_cast(&__trans_tmp_1);
  return n;
}
availability varpool_node::get_availability(symtab_node *ref) {
  if (definition && in_other_partition)
return AVAIL_NOT_AVAILABLE;
  ultimate_alias_target(ref);
  contains_struct_check(0, TS_DECL_COMMON, "", 5, __FUNCTION__);
  return AVAIL_AVAILABLE;
}

[Bug bootstrap/101374] [12 Regression] bootstrap failure varpool.c:490:19: error: array subscript 'varpool_node[0]' is partly outside array bounds of 'varpool_node [0]' [-Werror=array-bounds]

2021-07-08 Thread rguenth at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101374

--- Comment #3 from Richard Biener  ---
The following fails with -O2 -Wall -Werror after but not before the rev. - not
sure if the reduction is otherwise sensible.

template  struct reinterpret_is_a_helper {
  template  static T cast(U p) { return T(p); }
};
template  bool is_a(U);
template  T dyn_cast(U p) {
  if (is_a(p))
return reinterpret_is_a_helper::cast(p);
  return 0;
}
enum tree_node_structure_enum { TS_DECL_COMMON };
void contains_struct_check(int, tree_node_structure_enum, const char *, int,
   const char *);
enum availability { AVAIL_NOT_AVAILABLE, AVAIL_AVAILABLE };
struct symtab_node {
  symtab_node *ultimate_alias_target();
  unsigned definition : 1;
  unsigned in_other_partition : 1;
};
struct varpool_node : symtab_node {
  availability get_availability();
  varpool_node *ultimate_alias_target(symtab_node *);
  unsigned : 1;
};
inline symtab_node *symtab_node::ultimate_alias_target() {
  dyn_cast(this)->get_availability();
  dyn_cast(this)->get_availability();
  return 0;
}
inline varpool_node *varpool_node::ultimate_alias_target(symtab_node *) {
  symtab_node __trans_tmp_1 = *symtab_node::ultimate_alias_target();
  varpool_node *n = dyn_cast(&__trans_tmp_1);
  return n;
}
availability varpool_node::get_availability() {
  symtab_node ref;
  if (definition && in_other_partition)
return AVAIL_NOT_AVAILABLE;
  ultimate_alias_target();
  contains_struct_check(0, TS_DECL_COMMON, "", 5, __FUNCTION__);
  return AVAIL_AVAILABLE;
}

> /tmp/obj2/prev-gcc/cc1plus -quiet varpool.ii -O2 -Wall -Werror 
In member function 'availability varpool_node::get_availability()',
inlined from 'symtab_node* symtab_node::ultimate_alias_target()' at
varpool.ii:25:51,
inlined from 'varpool_node*
varpool_node::ultimate_alias_target(symtab_node*)' at varpool.ii:30:66,
inlined from 'availability
varpool_node::_ZN12varpool_node16get_availabilityEv.part.0()' at
varpool.ii:38:24:
varpool.ii:36:18: error: array subscript 'varpool_node[0]' is partly outside
array bounds of 'varpool_node [0]' [-Werror=array-bounds]
   36 |   if (definition && in_other_partition)
  |   ~~~^
varpool.ii: In member function 'availability
varpool_node::_ZN12varpool_node16get_availabilityEv.part.0()':
varpool.ii:19:8: note: object 'varpool_node::' of size 4
   19 | struct varpool_node : symtab_node {
  |^~~~
In member function 'availability varpool_node::get_availability()',
inlined from 'symtab_node* symtab_node::ultimate_alias_target()' at
varpool.ii:26:51,
inlined from 'varpool_node*
varpool_node::ultimate_alias_target(symtab_node*)' at varpool.ii:30:66,
inlined from 'availability
varpool_node::_ZN12varpool_node16get_availabilityEv.part.0()' at
varpool.ii:38:24:
varpool.ii:36:18: error: array subscript 'varpool_node[0]' is partly outside
array bounds of 'varpool_node [0]' [-Werror=array-bounds]
   36 |   if (definition && in_other_partition)
  |   ~~~^
varpool.ii: In member function 'availability
varpool_node::_ZN12varpool_node16get_availabilityEv.part.0()':
varpool.ii:19:8: note: object 'varpool_node::' of size 4
   19 | struct varpool_node : symtab_node {
  |^~~~
cc1plus: all warnings being treated as errors

[Bug bootstrap/101374] [12 Regression] bootstrap failure varpool.c:490:19: error: array subscript 'varpool_node[0]' is partly outside array bounds of 'varpool_node [0]' [-Werror=array-bounds]

2021-07-08 Thread rguenth at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101374

--- Comment #2 from Richard Biener  ---
I'm reducing a testcase for the varpool.c warning.

[Bug bootstrap/101374] [12 Regression] bootstrap failure varpool.c:490:19: error: array subscript 'varpool_node[0]' is partly outside array bounds of 'varpool_node [0]' [-Werror=array-bounds]

2021-07-08 Thread rguenth at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101374

--- Comment #1 from Richard Biener  ---
Reverting g:a110855667782dac7b674d3e328b253b3b3c919b gets me past this failure
point.

I'll note the printed location is bogus as well, it points to

/* Return variable availability.  See cgraph.h for description of individual
   return values.  */
enum availability
varpool_node::get_availability (symtab_node *ref)
{
  if (!definition && !in_other_partition)   <
return AVAIL_NOT_AVAILABLE;
  if (!TREE_PUBLIC (decl))

it might eventually warn on this->definition though?

[Bug bootstrap/101374] [12 Regression] bootstrap failure varpool.c:490:19: error: array subscript 'varpool_node[0]' is partly outside array bounds of 'varpool_node [0]' [-Werror=array-bounds]

2021-07-08 Thread rguenth at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101374

Richard Biener  changed:

   What|Removed |Added

 CC||msebor at gcc dot gnu.org
   Keywords||diagnostic
 Target||x86_64-*-*
   Target Milestone|--- |12.0