Patchwork [C++,Patch/RFC] PR 56450

login
register
mail settings
Submitter Paolo Carlini
Date April 28, 2013, 8:31 p.m.
Message ID <517D8731.80708@oracle.com>
Download mbox | patch
Permalink /patch/240306/
State New
Headers show

Comments

Paolo Carlini - April 28, 2013, 8:31 p.m.
Hi,

On 04/28/2013 09:10 PM, Jason Merrill wrote:
> On 04/27/2013 05:17 PM, Paolo Carlini wrote:
>> Assuming as obvious that we don't want to crash on it, the interesting
>> issue is whether we want the static_asserts to both fail or succeed: in
>> practice, a rather recent ICC I have at hand fails both; a rather recent
>> clang++ passes both (consistently with the expectation of Bug
>> submitter). In fact, as I'm reading now 7.1.6.2/4, since we are dealing
>> with a class member access in any case, it may well be possible that
>> *ICC* is right.
>
> Yes, I think so.  Since it's a class member access, decltype should be 
> the declared type, i.e. const int.
Thanks. Is the below Ok, then? Tested (again) on x86_64-linux.

Thanks,
Paolo.

//////////////////////////
/cp
2013-04-28  Paolo Carlini  <paolo.carlini@oracle.com>

	PR c++/56450
	* semantics.c (finish_decltype_type): Handle COMPOUND_EXPR.

/testsuite
2013-04-28  Paolo Carlini  <paolo.carlini@oracle.com>

	PR c++/56450
	* testsuite/g++.dg/cpp0x/decltype52.C: New.
Jason Merrill - April 28, 2013, 9:55 p.m.
OK.

Jason

Patch

Index: cp/semantics.c
===================================================================
--- cp/semantics.c	(revision 198366)
+++ cp/semantics.c	(working copy)
@@ -5398,6 +5398,7 @@  finish_decltype_type (tree expr, bool id_expressio
           break;
 
         case COMPONENT_REF:
+	case COMPOUND_EXPR:
 	  mark_type_use (expr);
           type = is_bitfield_expr_with_lowered_type (expr);
           if (!type)
Index: testsuite/g++.dg/cpp0x/decltype52.C
===================================================================
--- testsuite/g++.dg/cpp0x/decltype52.C	(revision 0)
+++ testsuite/g++.dg/cpp0x/decltype52.C	(working copy)
@@ -0,0 +1,18 @@ 
+// PR c++/56450
+// { dg-do compile { target c++11 } }
+
+template<typename T>
+T&& declval();
+
+template<typename, typename>
+struct is_same
+{ static constexpr bool value = false; };
+
+template<typename T>
+struct is_same<T, T>
+{ static constexpr bool value = true; };
+
+struct A { static const int dummy = 0; };
+
+static_assert(is_same<decltype(declval<A>().dummy), const int>::value, "");
+static_assert(!is_same<decltype(declval<A>().dummy), const int&>::value, "");