Patchwork C++ PATCH for c++/50034 (wrong error on passing to ... in unevaluated context)

login
register
mail settings
Submitter Jason Merrill
Date Aug. 12, 2011, 9:24 p.m.
Message ID <4E4599F7.8040601@redhat.com>
Download mbox | patch
Permalink /patch/109899/
State New
Headers show

Comments

Jason Merrill - Aug. 12, 2011, 9:24 p.m.
G++ was complaining about performing the lvalue-rvalue conversion on an 
lvalue of abstract type, which is correct when the conversion is 
potentially evaluated, but as it turns out, not in unevaluated context.

Tested x86_64-pc-linux-gnu, applying to trunk.

Patch

commit 28e405968ae794fcb73d2946a6c83bde167cc2ae
Author: Jason Merrill <jason@redhat.com>
Date:   Fri Aug 12 00:37:14 2011 -0400

    	PR c++/50034
    	* call.c (convert_arg_to_ellipsis): force_rvalue only in
    	potentially evaluated context.

diff --git a/gcc/cp/call.c b/gcc/cp/call.c
index a3b0f8a..e8fb68d 100644
--- a/gcc/cp/call.c
+++ b/gcc/cp/call.c
@@ -6097,7 +6097,7 @@  convert_arg_to_ellipsis (tree arg)
     {
       /* Build up a real lvalue-to-rvalue conversion in case the
 	 copy constructor is trivial but not callable.  */
-      if (CLASS_TYPE_P (arg_type))
+      if (!cp_unevaluated_operand && CLASS_TYPE_P (arg_type))
 	force_rvalue (arg, tf_warning_or_error);
 
       /* [expr.call] 5.2.2/7:
diff --git a/gcc/testsuite/g++.dg/cpp0x/defaulted28.C b/gcc/testsuite/g++.dg/cpp0x/defaulted28.C
index 15caef6..bcbf763 100644
--- a/gcc/testsuite/g++.dg/cpp0x/defaulted28.C
+++ b/gcc/testsuite/g++.dg/cpp0x/defaulted28.C
@@ -1,4 +1,5 @@ 
 // PR c++/49102
+// PR c++/50034
 // { dg-options -std=c++0x }
 
 struct A {
@@ -8,8 +9,9 @@  private:
   A(A const&) = default;	// { dg-error "private" }
 };
 
-void f(...) { }
+int f(...) { }
 int main() {
   A a;
   f(a); 			// { dg-error "this context" }
+  sizeof(f(a));			// OK because unevaluated
 }