https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104068
Bug ID: 104068 Summary: ICE Segmentation fault with type alias Product: gcc Version: 10.2.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: marc.rivinius.sec at gmail dot com Target Milestone: --- Created attachment 52212 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=52212&action=edit Preprocessed source I encountered an ICE (segmentation fault) in gcc version 10.2.1 (exact version and configuration below). Note: All version of x86-64 gcc >= 6.1.0 I tested on Compiler Explorer show this behavior: https://godbolt.org/z/5eYaP87hW Compiler input/output: $ gcc -v -save-temps -Wall -Wextra -Wpedantic -Werror -c bug.cpp Using built-in specs. COLLECT_GCC=gcc OFFLOAD_TARGET_NAMES=nvptx-none:amdgcn-amdhsa:hsa OFFLOAD_TARGET_DEFAULT=1 Target: x86_64-linux-gnu Configured with: ../src/configure -v --with-pkgversion='Debian 10.2.1-6' --with-bugurl=file:///usr/share/doc/gcc-10/README.Bugs --enable-languages=c,ada,c++,go,brig,d,fortran,objc,obj-c++,m2 --prefix=/usr --with-gcc-major-version-only --program-suffix=-10 --program-prefix=x86_64-linux-gnu- --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --enable-bootstrap --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-vtable-verify --enable-plugin --enable-default-pie --with-system-zlib --enable-libphobos-checking=release --with-target-system-zlib=auto --enable-objc-gc=auto --enable-multiarch --disable-werror --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic --enable-offload-targets=nvptx-none=/build/gcc-10-Km9U7s/gcc-10-10.2.1/debian/tmp-nvptx/usr,amdgcn-amdhsa=/build/gcc-10-Km9U7s/gcc-10-10.2.1/debian/tmp-gcn/usr,hsa --without-cuda-driver --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu --with-build-config=bootstrap-lto-lean --enable-link-mutex Thread model: posix Supported LTO compression algorithms: zlib zstd gcc version 10.2.1 20210110 (Debian 10.2.1-6) COLLECT_GCC_OPTIONS='-v' '-save-temps' '-Wall' '-Wextra' '-Wpedantic' '-Werror' '-c' '-mtune=generic' '-march=x86-64' /usr/lib/gcc/x86_64-linux-gnu/10/cc1plus -E -quiet -v -imultiarch x86_64-linux-gnu -D_GNU_SOURCE bug.cpp -mtune=generic -march=x86-64 -Wall -Wextra -Wpedantic -Werror -fpch-preprocess -fasynchronous-unwind-tables -o bug.ii ignoring duplicate directory "/usr/include/x86_64-linux-gnu/c++/10" ignoring nonexistent directory "/usr/local/include/x86_64-linux-gnu" ignoring nonexistent directory "/usr/lib/gcc/x86_64-linux-gnu/10/include-fixed" ignoring nonexistent directory "/usr/lib/gcc/x86_64-linux-gnu/10/../../../../x86_64-linux-gnu/include" #include "..." search starts here: #include <...> search starts here: /usr/include/c++/10 /usr/include/x86_64-linux-gnu/c++/10 /usr/include/c++/10/backward /usr/lib/gcc/x86_64-linux-gnu/10/include /usr/local/include /usr/include/x86_64-linux-gnu /usr/include End of search list. COLLECT_GCC_OPTIONS='-v' '-save-temps' '-Wall' '-Wextra' '-Wpedantic' '-Werror' '-c' '-mtune=generic' '-march=x86-64' /usr/lib/gcc/x86_64-linux-gnu/10/cc1plus -fpreprocessed bug.ii -quiet -dumpbase bug.cpp -mtune=generic -march=x86-64 -auxbase bug -Wall -Wextra -Wpedantic -Werror -version -fasynchronous-unwind-tables -o bug.s GNU C++14 (Debian 10.2.1-6) version 10.2.1 20210110 (x86_64-linux-gnu) compiled by GNU C version 10.2.1 20210110, GMP version 6.2.1, MPFR version 4.1.0, MPC version 1.2.0, isl version isl-0.23-GMP GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072 GNU C++14 (Debian 10.2.1-6) version 10.2.1 20210110 (x86_64-linux-gnu) compiled by GNU C version 10.2.1 20210110, GMP version 6.2.1, MPFR version 4.1.0, MPC version 1.2.0, isl version isl-0.23-GMP GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072 Compiler executable checksum: 048fcaee3460a99eb0d68522358720e1 bug.cpp: In instantiation of ‘struct view<traits<int> >’: bug.cpp:41:17: required from here bug.cpp:35:48: internal compiler error: Segmentation fault 35 | constexpr view_with_extent<Traits, Extent> subview(constant<size_type, Extent>) const noexcept | ^~~~~~~ 0x7fdd395c2d5f ??? ./signal/../sysdeps/unix/sysv/linux/x86_64/sigaction.c:0 0x7fdd395add09 __libc_start_main ../csu/libc-start.c:308 Please submit a full bug report, with preprocessed source if appropriate. Please include the complete backtrace with any bug report. See <file:///usr/share/doc/gcc-10/README.Bugs> for instructions. --- gcc 11.X gives more details (on Compiler Explorer): <source>: In instantiation of 'struct view<traits<int> >': <source>:41:17: required from here <source>:35:48: internal compiler error: Segmentation fault 35 | constexpr view_with_extent<Traits, Extent> subview(constant<size_type, Extent>) const noexcept | ^~~~~~~ 0x1786229 internal_error(char const*, ...) ???:0 0x7dd289 tsubst(tree_node*, tree_node*, int, tree_node*) ???:0 0x7edc30 tsubst_template_arg(tree_node*, tree_node*, int, tree_node*) ???:0 0x7ef008 tsubst_template_args(tree_node*, tree_node*, int, tree_node*) ???:0 0x7dd864 tsubst(tree_node*, tree_node*, int, tree_node*) ???:0 0x7de88b tsubst(tree_node*, tree_node*, int, tree_node*) ???:0 0x7dd40d tsubst(tree_node*, tree_node*, int, tree_node*) ???:0 0x7ddad6 tsubst(tree_node*, tree_node*, int, tree_node*) ???:0 0x7edc30 tsubst_template_arg(tree_node*, tree_node*, int, tree_node*) ???:0 0x7ef008 tsubst_template_args(tree_node*, tree_node*, int, tree_node*) ???:0 0x7dd7cc tsubst(tree_node*, tree_node*, int, tree_node*) ???:0 0x7dd5ae tsubst(tree_node*, tree_node*, int, tree_node*) ???:0 0x7dd8a7 tsubst(tree_node*, tree_node*, int, tree_node*) ???:0 0x7f9ecb instantiate_class_template(tree_node*) ???:0 0x82d1b3 complete_type(tree_node*) ???:0 0x7fb17b do_type_instantiation(tree_node*, tree_node*, int) ???:0 0x7c47db c_parse_file() ???:0 0x896762 c_common_parse_file() ???:0 Please submit a full bug report, with preprocessed source if appropriate. --- Different definitions of size_type in view_with_extent avoid the ICE. using size_type = typename Traits::size_type; // would fix the problem using size_type = unsigned; // would also fix the problem