* tree.c (strip_typedefs): Skip the attribute handling if T is
a variant type which hasn't been updated yet.
+ PR c++/79687 - wrong code with pointer-to-member
+ * init.c (constant_value_1): Break if the variable has a dynamic
+ initializer.
+
2017-03-08 Jason Merrill <jason@redhat.com>
PR c++/79797 - ICE with self-reference in array DMI.
if (TREE_CODE (init) == CONSTRUCTOR
&& !DECL_INITIALIZED_BY_CONSTANT_EXPRESSION_P (decl))
break;
+ /* If the variable has a dynamic initializer, don't use its
+ DECL_INITIAL which doesn't reflect the real value. */
+ if (VAR_P (decl)
+ && TREE_STATIC (decl)
+ && !DECL_INITIALIZED_BY_CONSTANT_EXPRESSION_P (decl)
+ && DECL_NONTRIVIALLY_INITIALIZED_P (decl))
+ break;
decl = unshare_expr (init);
}
return decl;
+2017-03-09 Marek Polacek <polacek@redhat.com>
+
+ PR c++/79687
+ * g++.dg/expr/ptrmem8.C: New test.
+ * g++.dg/expr/ptrmem9.C: New test.
+
2017-03-09 Richard Biener <rguenther@suse.de>
PR tree-optimization/79977
--- /dev/null
+// PR c++/79687
+// { dg-do run }
+
+struct A
+{
+ char c;
+};
+
+int main()
+{
+ char A::* p = &A::c;
+ static char A::* const q = p;
+ A a;
+ return &(a.*q) - &a.c;
+}
--- /dev/null
+// PR c++/79687
+// { dg-do run }
+
+struct A
+{
+ char c;
+};
+
+int main()
+{
+ static char A::* p1 = &A::c;
+ char A::* const q1 = p1;
+
+ char A::* p2 = &A::c;
+ static char A::* const q2 = p2;
+
+ A a;
+ return (&(a.*q1) - &a.c) || (&(a.*q2) - &a.c);
+}