diff options
Diffstat (limited to 'gcc/cp/init.c')
-rw-r--r-- | gcc/cp/init.c | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/gcc/cp/init.c b/gcc/cp/init.c index fefda4b810d..50303456991 100644 --- a/gcc/cp/init.c +++ b/gcc/cp/init.c @@ -2276,7 +2276,13 @@ build_new_1 (tree exp) } /* Convert to the final type. */ - return build_nop (pointer_type, rval); + rval = build_nop (pointer_type, rval); + + /* A new-expression is never an lvalue. */ + if (real_lvalue_p (rval)) + rval = build1 (NON_LVALUE_EXPR, TREE_TYPE (rval), rval); + + return rval; } static tree |