https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82936
Bug ID: 82936 Summary: segment fault crash for non-type template parameter Product: gcc Version: 7.2.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: lizhenhuan1019 at qq dot com Target Milestone: --- Created attachment 42577 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=42577&action=edit The test case. Tried to compile the following code but gcc 7.2.0 crashed with segment fault. Neither diagnostic message nor output file were generated. Tested on Arch Linux x64 and windows 10 x64(using MSYS2 in Mingw-w64 mode) and both crashed. Also tested on online compiler wandbox.org and the same occurred. The code(small enough): #include <utility> int fun(int i) { return 0; } template<typename F> struct outer; template<typename R, typename ...Args> struct outer<R(Args...)> { template<R(&f)(Args...)> struct callable { template <typename...T> R operator()(T&&...t) { return f(std::forward<T>(t)...); } }; }; int main() { outer<int(int)>::callable<fun> f;//this line triggered the bug. return 0; } //the code ends. On Arch Linux: The command used to compile the test case was g++ main.cpp The error output of g++ main.cpp -v -save-temps : **begin: Using built-in specs. COLLECT_GCC=g++ COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-pc-linux-gnu/7.2.0/lto-wrapper Target: x86_64-pc-linux-gnu Configured with: /build/gcc/src/gcc/configure --prefix=/usr --libdir=/usr/lib --libexecdir=/usr/lib --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=https://bugs.archlinux.org/ --enable-languages=c,c++,ada,fortran,go,lto,objc,obj-c++ --enable-shared --enable-threads=posix --enable-libmpx --with-system-zlib --with-isl --enable-__cxa_atexit --disable-libunwind-exceptions --enable-clocale=gnu --disable-libstdcxx-pch --disable-libssp --enable-gnu-unique-object --enable-linker-build-id --enable-lto --enable-plugin --enable-install-libiberty --with-linker-hash-style=gnu --enable-gnu-indirect-function --disable-multilib --disable-werror --enable-checking=release --enable-default-pie --enable-default-ssp Thread model: posix gcc version 7.2.0 (GCC) COLLECT_GCC_OPTIONS='-v' '-save-temps' '-shared-libgcc' '-mtune=generic' '-march=x86-64' /usr/lib/gcc/x86_64-pc-linux-gnu/7.2.0/cc1plus -E -quiet -v -D_GNU_SOURCE main.cpp -mtune=generic -march=x86-64 -fpch-preprocess -o main.ii ignoring nonexistent directory "/usr/lib/gcc/x86_64-pc-linux-gnu/7.2.0/../../../../x86_64-pc-linux-gnu/include" #include "..." search starts here: #include <...> search starts here: /usr/lib/gcc/x86_64-pc-linux-gnu/7.2.0/../../../../include/c++/7.2.0 /usr/lib/gcc/x86_64-pc-linux-gnu/7.2.0/../../../../include/c++/7.2.0/x86_64-pc-linux-gnu /usr/lib/gcc/x86_64-pc-linux-gnu/7.2.0/../../../../include/c++/7.2.0/backward /usr/lib/gcc/x86_64-pc-linux-gnu/7.2.0/include /usr/local/include /usr/lib/gcc/x86_64-pc-linux-gnu/7.2.0/include-fixed /usr/include End of search list. COLLECT_GCC_OPTIONS='-v' '-save-temps' '-shared-libgcc' '-mtune=generic' '-march=x86-64' /usr/lib/gcc/x86_64-pc-linux-gnu/7.2.0/cc1plus -fpreprocessed main.ii -quiet -dumpbase main.cpp -mtune=generic -march=x86-64 -auxbase main -version -o main.s GNU C++14 (GCC) version 7.2.0 (x86_64-pc-linux-gnu) compiled by GNU C version 7.2.0, GMP version 6.1.2, MPFR version 3.1.5-p2, MPC version 1.0.3, isl version isl-0.18-GMP GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072 GNU C++14 (GCC) version 7.2.0 (x86_64-pc-linux-gnu) compiled by GNU C version 7.2.0, GMP version 6.1.2, MPFR version 3.1.5-p2, MPC version 1.0.3, isl version isl-0.18-GMP GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072 Compiler executable checksum: 5931a2fe3d5a5365a85e56248f3f55d7 g++: internal compiler error: Segmentation fault (program cc1plus) Please submit a full bug report, with preprocessed source if appropriate. See <https://bugs.archlinux.org/> for instructions. ** end: