https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102326
Bug ID: 102326 Summary: ICE in tree_to_uhwi, at tree.c:4520 Product: gcc Version: 10.2.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: pc.wang at linux dot alibaba.com Target Milestone: --- Created attachment 51459 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=51459&action=edit A patch that may fix this bug If there exists static local variable of variable-length vector type(like types in AARCH64 SVE and RISCV Vector Extension) in C++ template, like: ``` #include <arm_sve.h> template <int N> void f() { int i = 0; static svbool_t pg = svwhilelt_b64(0, N); } int main(int argc, char **argv) { f<2>(); return 0; } ``` GCC raises an ICE like: ``` static-var-in-template.cpp:14:1: internal compiler error: in tree_to_uhwi, at tree.h:4520 14 | } | ^ ``` And here is the version of GCC: ``` Using built-in specs. COLLECT_GCC=aarch64-none-linux-gnu-g++ COLLECT_LTO_WRAPPER=/lhome/wangpc/software/arm/bin/../libexec/gcc/aarch64-none-linux-gnu/10.2.1/lto-wrapper Target: aarch64-none-linux-gnu Configured with: /tmp/dgboter/bbs/build04--cen7x86_64/buildbot/cen7x86_64--aarch64-none-linux-gnu/build/src/gcc/configure --target=aarch64-none-linux-gnu --prefix= --with-sysroot=/aarch64-none-linux-gnu/libc --with-build-sysroot=/tmp/dgboter/bbs/build04--cen7x86_64/buildbot/cen7x86_64--aarch64-none-linux-gnu/build/build-aarch64-none-linux-gnu/install//aarch64-none-linux-gnu/libc --with-bugurl=https://bugs.linaro.org/ --enable-gnu-indirect-function --enable-shared --disable-libssp --disable-libmudflap --enable-checking=release --enable-languages=c,c++,fortran --with-gmp=/tmp/dgboter/bbs/build04--cen7x86_64/buildbot/cen7x86_64--aarch64-none-linux-gnu/build/build-aarch64-none-linux-gnu/host-tools --with-mpfr=/tmp/dgboter/bbs/build04--cen7x86_64/buildbot/cen7x86_64--aarch64-none-linux-gnu/build/build-aarch64-none-linux-gnu/host-tools --with-mpc=/tmp/dgboter/bbs/build04--cen7x86_64/buildbot/cen7x86_64--aarch64-none-linux-gnu/build/build-aarch64-none-linux-gnu/host-tools --with-isl=/tmp/dgboter/bbs/build04--cen7x86_64/buildbot/cen7x86_64--aarch64-none-linux-gnu/build/build-aarch64-none-linux-gnu/host-tools --enable-fix-cortex-a53-843419 --with-pkgversion='GNU Toolchain for the A-profile Architecture 10.2-2020.11 (arm-10.16)' Thread model: posix Supported LTO compression algorithms: zlib gcc version 10.2.1 20201103 (GNU Toolchain for the A-profile Architecture 10.2-2020.11 (arm-10.16)) ``` The lack of type checking (defined by hook `TARGET_VERIFY_TYPE_CONTEXT`) after instantiation is the reason, since SVE/RVV types can't be static.