https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79687
--- Comment #20 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
Oh well. Anyway, this
--- a/gcc/cp/cp-gimplify.c
+++ b/gcc/cp/cp-gimplify.c
@@ -1973,7 +1973,8 @@ cp_fold_maybe_rvalue (tree x, bool rval)
{
x = cp_fold (x);
if (rval && DECL_P (x)
- && TREE_CODE (TREE_TYPE (x)) != REFERENCE_TYPE)
+ && TREE_CODE (TREE_TYPE (x)) != REFERENCE_TYPE
+ && !TYPE_PTRDATAMEM_P (TREE_TYPE (x)))
{
tree v = decl_constant_value (x);
if (v != x && v != error_mark_node)
fixes the original testcase, as well as the one Comment 4 and in Comment 11.