https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63649
Bug ID: 63649 Summary: 5.0: ICE with init_priority Product: gcc Version: 5.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: adam at os dot inf.tu-dresden.de The following code causes an ICE: struct Per_cpu_ctor_data { typedef void (*Func)(); Per_cpu_ctor_data() = default; void *_base; }; class Per_cpu_data { private: typedef Per_cpu_ctor_data Ctor; struct Ctor_vector { void push_back(Ctor::Func func); }; static Ctor_vector ctors; }; template< typename T > class Per_cpu : private Per_cpu_data { public: typedef T Type; Per_cpu(); static void f1(); }; template< typename T > Per_cpu<T>::Per_cpu() { ctors.push_back(&f1); } template< typename T > void Per_cpu<T>::f1() {} class A { static Per_cpu<int *> a; }; static Per_cpu_ctor_data __b; __attribute__((init_priority(0xfffe))) Per_cpu<int *> A::a; $ g++ --version g++ (GCC) 5.0.0 20141026 (experimental) $ uname -m x86_64 $ g++ -c -std=c++0x -O1 t.i mem_space.i:31:59: internal compiler error: Segmentation fault __attribute__((init_priority(0xfffe))) Per_cpu<int *> A::a; ^ 0xc022af crash_signal ../../gcc/gcc/toplev.c:349 0x11df22c ipa_comdats ../../gcc/gcc/ipa-comdats.c:330 0x11df22c execute ../../gcc/gcc/ipa-comdats.c:371 Please submit a full bug report, with preprocessed source if appropriate. Please include the complete backtrace with any bug report. See <http://gcc.gnu.org/bugs.html> for instructions. I could not reduce the testcase more as the segfault would not happen. The segfault also does not happen with -O0, and it also does not happen with init_priority 0xffff. Code compiles with gcc <= 4.9.