diff options
Diffstat (limited to 'gcc/cp/call.c')
-rw-r--r-- | gcc/cp/call.c | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/gcc/cp/call.c b/gcc/cp/call.c index 637671bc1bc..00e0c063e86 100644 --- a/gcc/cp/call.c +++ b/gcc/cp/call.c @@ -4664,10 +4664,14 @@ convert_default_arg (tree type, tree arg, tree fn, int parmnum) } else { - /* This could get clobbered by the following call. */ - if (TREE_HAS_CONSTRUCTOR (arg)) + /* We must make a copy of ARG, in case subsequent processing + alters any part of it. For example, during gimplification a + cast of the form (T) &X::f (where "f" is a member function) + will lead to replacing the PTRMEM_CST for &X::f with a + VAR_DECL. We can avoid the copy for constants, since they + are never modified in place. */ + if (!CONSTANT_CLASS_P (arg)) arg = copy_node (arg); - arg = convert_for_initialization (0, type, arg, LOOKUP_NORMAL, "default argument", fn, parmnum); arg = convert_for_arg_passing (type, arg); |