https://gcc.gnu.org/bugzilla/show_bug.cgi?id=119941

            Bug ID: 119941
           Summary: -Warray-bounds warning in
                    adjust_offset_for_component_ref when building for
                    bpf-unknown-none
           Product: gcc
           Version: 16.0
            Status: UNCONFIRMED
          Keywords: build
          Severity: normal
          Priority: P3
         Component: middle-end
          Assignee: unassigned at gcc dot gnu.org
          Reporter: sjames at gcc dot gnu.org
  Target Milestone: ---

When building a cross-compiler for bpf-unknown-none with LTO and -O3, I saw:
```
In function ‘canonize’,
    inlined from ‘arshift_large’ at
/var/tmp/portage/sys-devel/bpf-toolchain-15.1.0_p1/work/gcc/gcc/wide-int.cc:2173:19,
    inlined from ‘arshift’ at
/var/tmp/portage/sys-devel/bpf-toolchain-15.1.0_p1/work/gcc/gcc/wide-int.h:3700:17,
    inlined from ‘operator>>’ at
/var/tmp/portage/sys-devel/bpf-toolchain-15.1.0_p1/work/gcc/gcc/wide-int.h:3871:22,
    inlined from
‘_ZL31adjust_offset_for_component_refP9tree_nodePbP8poly_intILj1ElE.part.0’ at
/var/tmp/portage/sys-devel/bpf-toolchain-15.1.0_p1/work/gcc/gcc/alias.cc:2793:11:
/var/tmp/portage/sys-devel/bpf-toolchain-15.1.0_p1/work/gcc/gcc/wide-int.cc:95:7:
warning: array subscript 4294967295 is outside array bounds of ‘struct
signed_shift_result_type[1]’ [-Warray-bounds=]
   95 |   top = val[len - 1];
      |       ^
  ‘_ZL31adjust_offset_for_component_refP9tree_nodePbP8poly_intILj1ElE.part.0’:
events 1-2
   92 |   if (len == 1)
      |   ^
      |   |
      |   (1) when the condition is evaluated to false
......
   95 |   top = val[len - 1];
      |       ~
      |       |
      |       (2) out of array bounds here
/var/tmp/portage/sys-devel/bpf-toolchain-15.1.0_p1/work/gcc/gcc/alias.cc: In
function
‘_ZL31adjust_offset_for_component_refP9tree_nodePbP8poly_intILj1ElE.part.0’:
/var/tmp/portage/sys-devel/bpf-toolchain-15.1.0_p1/work/gcc/gcc/alias.cc:2793:18:
note: at offset 34359738360 into object ‘<anonymous>’ of size 24
 2793 |               >> LOG2_BITS_PER_UNIT)
      |                  ^
In function ‘canonize’,
    inlined from ‘arshift_large’ at
/var/tmp/portage/sys-devel/bpf-toolchain-15.1.0_p1/work/gcc/gcc/wide-int.cc:2173:19,
    inlined from ‘arshift’ at
/var/tmp/portage/sys-devel/bpf-toolchain-15.1.0_p1/work/gcc/gcc/wide-int.h:3700:17,
    inlined from ‘operator>>’ at
/var/tmp/portage/sys-devel/bpf-toolchain-15.1.0_p1/work/gcc/gcc/wide-int.h:3871:22,
    inlined from
‘_ZL31adjust_offset_for_component_refP9tree_nodePbP8poly_intILj1ElE.part.0’ at
/var/tmp/portage/sys-devel/bpf-toolchain-15.1.0_p1/work/gcc/gcc/alias.cc:2793:11:
/var/tmp/portage/sys-devel/bpf-toolchain-15.1.0_p1/work/gcc/gcc/wide-int.cc:95:7:
warning: array subscript 4294967295 is outside array bounds of ‘struct
signed_shift_result_type[1]’ [-Warray-bounds=]
   95 |   top = val[len - 1];
      |       ^
  ‘_ZL31adjust_offset_for_component_refP9tree_nodePbP8poly_intILj1ElE.part.0’:
events 1-2
   92 |   if (len == 1)
      |   ^
      |   |
      |   (1) when the condition is evaluated to false
......
   95 |   top = val[len - 1];
      |       ~
      |       |
      |       (2) out of array bounds here
/var/tmp/portage/sys-devel/bpf-toolchain-15.1.0_p1/work/gcc/gcc/alias.cc: In
function
‘_ZL31adjust_offset_for_component_refP9tree_nodePbP8poly_intILj1ElE.part.0’:
/var/tmp/portage/sys-devel/bpf-toolchain-15.1.0_p1/work/gcc/gcc/alias.cc:2793:18:
note: at offset 34359738360 into object ‘<anonymous>’ of size 24
 2793 |               >> LOG2_BITS_PER_UNIT)
```

Reply via email to