@@ -1210,24 +1210,6 @@ namespace MemberPointer {
12101210 return (a.*f)();
12111211 }
12121212 static_assert (apply(A(2 ), &A::f) == 5 , " " );
1213-
1214- struct C { };
1215- struct D : C {
1216- constexpr int f () const { return 1 ; };
1217- };
1218- struct E : C { };
1219- struct F : D { };
1220- constexpr C c1, c2[2 ];
1221- constexpr D d1, d2[2 ];
1222- constexpr E e1 , e2 [2 ];
1223- constexpr F f;
1224- static_assert ((c1.*(static_cast <int (C::*)() const >(&D::f)))() == 1 , " " ); // expected-error {{constant expression}}
1225- static_assert ((d1.*(static_cast <int (C::*)() const >(&D::f)))() == 1 , " " );
1226- static_assert ((e1 .*(static_cast <int (C::*)() const >(&D::f)))() == 1 , " " ); // expected-error {{constant expression}}
1227- static_assert ((f.*(static_cast <int (C::*)() const >(&D::f)))() == 1 , " " );
1228- static_assert ((c2[0 ].*(static_cast <int (C::*)() const >(&D::f)))() == 1 , " " ); // expected-error {{constant expression}}
1229- static_assert ((d2[0 ].*(static_cast <int (C::*)() const >(&D::f)))() == 1 , " " );
1230- static_assert ((e2 [0 ].*(static_cast <int (C::*)() const >(&D::f)))() == 1 , " " ); // expected-error {{constant expression}}
12311213}
12321214
12331215namespace ArrayBaseDerived {
@@ -2633,3 +2615,33 @@ namespace DoubleCapture {
26332615 };
26342616 }
26352617}
2618+
2619+ namespace GH150709 {
2620+ struct C { };
2621+ struct D : C {
2622+ constexpr int f () const { return 1 ; };
2623+ };
2624+ struct E : C { };
2625+ struct F : D { };
2626+ struct G : E { };
2627+
2628+ constexpr C c1, c2[2 ];
2629+ constexpr D d1, d2[2 ];
2630+ constexpr E e1 , e2 [2 ];
2631+ constexpr F f;
2632+ constexpr G g;
2633+
2634+ constexpr auto mp = static_cast <int (C::*)() const >(&D::f);
2635+
2636+ // sanity checks for fix of GH150709 (unchanged behavior)
2637+ static_assert ((c1.*mp)() == 1 , " " ); // expected-error {{constant expression}}
2638+ static_assert ((d1.*mp)() == 1 , " " );
2639+ static_assert ((f.*mp)() == 1 , " " );
2640+ static_assert ((c2[0 ].*mp)() == 1 , " " ); // expected-error {{constant expression}}
2641+ static_assert ((d2[0 ].*mp)() == 1 , " " );
2642+
2643+ // incorrectly undiagnosed before fix of GH150709
2644+ static_assert ((e1 .*mp)() == 1 , " " ); // expected-error {{constant expression}}
2645+ static_assert ((e2 [0 ].*mp)() == 1 , " " ); // expected-error {{constant expression}}
2646+ static_assert ((g.*mp)() == 1 , " " ); // expected-error {{constant expression}}
2647+ }
0 commit comments