gcc version 4.7.0 20111112 (experimental) (GCC) Two seemingly relate ICEs when dealing with pointer to member: struct foo { int a = 42; static int foo::*b = &foo::a; }; internal compiler error: Segmentation fault struct foo { int a = 42; static int foo::*b; auto& c = b; }; internal compiler error: in unify_one_argument, at cp/pt.c:15008 Not sure if the code is valid.
(In reply to comment #0) > gcc version 4.7.0 20111112 (experimental) (GCC) Also in 4.7.0 20111126 (experimental) > Two seemingly relate ICEs when dealing with pointer to member: > > struct foo { > int a = 42; > static int foo::*b = &foo::a; > }; b needs to have a constexpr specifier here, but it ICEs also with that one added. Even with the constexpr specifier that declaration should be ill-formed, because the class definition must be complete for an in-class static data member initializer. Also, the initializer for a is not needed to reproduce the error. > struct foo { > int a = 42; > static int foo::*b; > auto& c = b; > }; > internal compiler error: in unify_one_argument, at cp/pt.c:15008 The declaration of c cannot use auto (only static data members may do) and the ICE does no longer occur after the fix. In addition, the declaration of a is not needed to reproduce the problem.
(In reply to comment #1) > Even with the constexpr specifier that declaration should be ill-formed, > because the class definition must be complete for an in-class static data > member initializer. I just recognize that the class definition must not be complete to make the pointer of member formation a constant expression. So, the code of the first example should be well-formed after addition of constexpr to the static data member.
Created attachment 32899 [details] gcc -v result
Problem is still present in 4.8.2, reproduce with following code, which compiles in clang 3.4 (both with -std=c++11): struct Y { int o; static constexpr int Y::* x = &Y::o; }; gcc -v result included in previous comment. Tested on NixOS linux x86_64.
Fixed in 4.9.0 though
(In reply to Jonathan Wakely from comment #5) > Fixed in 4.9.0 though I'm glad to hear that, I could not yet installed 4.9.0 in my OS.
Fixed by r196852. *** This bug has been marked as a duplicate of bug 54532 ***