https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86182
Bug ID: 86182 Summary: gcc crashes when compiling the code Product: gcc Version: unknown Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: zhonghao at pku dot org.cn Target Milestone: --- The code is as follow: #include <stdio.h> template<typename T> static char const * f(T *t) { T u(*t); u.x = "hello world"; printf("%s\n", u.x); return "initialized"; } int main() { union { char const *x = f(this); }; printf("%s\n", x); } gcc++ produces errors messages: /home/haozhong/project/approach/otherreport/llvm/tmp/llvm_10531/code0.c.cpp: In function ‘const char* f(T*) [with T = main()::<unnamed union>]’: /home/haozhong/project/approach/otherreport/llvm/tmp/llvm_10531/code0.c.cpp:3:42: error:Local declaration from a different function template<typename T> static char const * f(T *t) { ^ D.2918 /home/haozhong/project/approach/otherreport/llvm/tmp/llvm_10531/code0.c.cpp:4:4: T u(*t); ^ _1 = &D.2918; /home/haozhong/project/approach/otherreport/llvm/tmp/llvm_10531/code0.c.cpp:3:42: error:Local declaration from a different function template<typename T> static char const * f(T *t) { ^ /home/haozhong/project/approach/otherreport/llvm/tmp/llvm_10531/code0.c.cpp:3:42: error:Local declaration from a different function during GIMPLE pass: cfg /home/haozhong/project/approach/otherreport/llvm/tmp/llvm_10531/code0.c.cpp:3:42: internal error:verify_gimple 失败 0xf11023 verify_gimple_in_cfg(function*, bool) ../../code/gcc/tree-cfg.c:5585 0xdf808f execute_function_todo ../../code/gcc/passes.c:1994 0xdf8fde execute_todo ../../code/gcc/passes.c:2048 Please include the complete backtrace with any bug report. The code comes from a bug report of clang++ https://bugs.llvm.org/show_bug.cgi?id=10531 The clang report can provide hints to understand the problem.