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

            Bug ID: 102395
           Summary: [nvptx, vax] enum reg_class inferred as signed /
                    unsigned
           Product: gcc
           Version: analyzer branch
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: middle-end
          Assignee: unassigned at gcc dot gnu.org
          Reporter: jbg...@lug-owl.de
  Target Milestone: ---

Created attachment 51477
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=51477&action=edit
Testcase

Running automated testing, I get similar errors then building for
--target=nvptx-none and vax-linux using a fairly recent GCC version:

$ .../configure --target=nvptx-none \
                --enable-werror-always \
                --enable-languages=all \
                --disable-gcov \
                --disable-shared \
                --disable-threads \
                --without-headers
[..]
$ make all-gcc
[...]
[all 2021-09-13 12:37:11] /usr/lib/gcc-snapshot/bin/g++  -fno-PIE -c   -g -O2
-DIN_GCC  -DCROSS_DIRECTORY_STRUCTURE   -fno-exceptions -fno-rtti
-fasynchronous-unwind-tables -W -Wall -Wno-narrowing -Wwrite-strings
-Wcast-qual -Wno-error=format-diag -Wmissing-format-attribute
-Woverloaded-virtual -pedantic -Wno-long-long -Wno-variadic-macros
-Wno-overlength-strings -Werror -fno-common  -DHAVE_CONFIG_H -I. -I.
-I../../gcc/gcc -I../../gcc/gcc/. -I../../gcc/gcc/../include
-I../../gcc/gcc/../libcpp/include -I../../gcc/gcc/../libcody 
-I../../gcc/gcc/../libdecnumber -I../../gcc/gcc/../libdecnumber/dpd
-I../libdecnumber -I../../gcc/gcc/../libbacktrace   -o lra-constraints.o -MT
lra-constraints.o -MMD -MP -MF ./.deps/lra-constraints.TPo
../../gcc/gcc/lra-constraints.c
[all 2021-09-13 12:37:20] In function 'bool check_and_process_move(bool*,
bool*)',
[all 2021-09-13 12:37:20]     inlined from 'bool curr_insn_transform(bool)' at
../../gcc/gcc/lra-constraints.c:4092:33:
[all 2021-09-13 12:37:20] ../../gcc/gcc/lra-constraints.c:1317:56: error: array
subscript -1 is below array bounds of 'short int [2][16]'
[-Werror=array-bounds]
[all 2021-09-13 12:37:20]  1317 |       reg_renumber[dregno] =
ira_class_hard_regs[dclass][0];
[all 2021-09-13 12:37:20] In file included from
../../gcc/gcc/lra-constraints.c:123:
[all 2021-09-13 12:37:20] ../../gcc/gcc/ira.h: In function 'bool
curr_insn_transform(bool)':
[all 2021-09-13 12:37:20] ../../gcc/gcc/ira.h:85:9: note: while referencing
'target_ira::x_ira_class_hard_regs'
[all 2021-09-13 12:37:20]    85 |   short
x_ira_class_hard_regs[N_REG_CLASSES][FIRST_PSEUDO_REGISTER];
[all 2021-09-13 12:37:20]       |         ^~~~~~~~~~~~~~~~~~~~~
[all 2021-09-13 12:37:20] In function 'bool check_and_process_move(bool*,
bool*)',
[all 2021-09-13 12:37:20]     inlined from 'bool curr_insn_transform(bool)' at
../../gcc/gcc/lra-constraints.c:4092:33:
[all 2021-09-13 12:37:20] ../../gcc/gcc/lra-constraints.c:1324:56: error: array
subscript -1 is below array bounds of 'short int [2][16]'
[-Werror=array-bounds]
[all 2021-09-13 12:37:20]  1324 |       reg_renumber[sregno] =
ira_class_hard_regs[sclass][0];
[all 2021-09-13 12:37:20] In file included from
../../gcc/gcc/lra-constraints.c:123:
[all 2021-09-13 12:37:20] ../../gcc/gcc/ira.h: In function 'bool
curr_insn_transform(bool)':
[all 2021-09-13 12:37:20] ../../gcc/gcc/ira.h:85:9: note: while referencing
'target_ira::x_ira_class_hard_regs'
[all 2021-09-13 12:37:20]    85 |   short
x_ira_class_hard_regs[N_REG_CLASSES][FIRST_PSEUDO_REGISTER];
[all 2021-09-13 12:37:20]       |         ^~~~~~~~~~~~~~~~~~~~~
[all 2021-09-13 12:37:26] cc1plus: all warnings being treated as errors
[all 2021-09-13 12:37:26] make[1]: *** [Makefile:1142: lra-constraints.o] Error
1
[all 2021-09-13 12:37:26] make[1]: Leaving directory
'/var/lib/laminar/run/gcc-nvptx-none/8/toolchain-build/gcc'
[all 2021-09-13 12:37:26] make: *** [Makefile:4407: all-gcc] Error 2

(Initial report can be found at
https://gcc.gnu.org/pipermail/gcc/2021-September/237237.html)

Martin Sebor already had a look at it (cf.
https://gcc.gnu.org/pipermail/gcc/2021-September/237383.html) and suggested to
explicitely make reg_class an unsigned enum, or to add gcc_unreachable() for <
0 to indicate the non-negativeness of sclass/dclass.

Preprocessed / minimized testcase attached (based on --target=nvptx-none),
build with a recent GCC:

g++ -c -O2 -Wall -o lra-constraints.o lra-constraints.ii

Reply via email to