diff mbox

c++/78765

Message ID ce8f08bb-bb16-0f87-1f9e-fc24da09d097@acm.org
State New
Headers show

Commit Message

Nathan Sidwell Jan. 4, 2017, 4:44 p.m. UTC
On 01/04/2017 10:13 AM, Jason Merrill wrote:

> OK, that looks like the problem; we shouldn't be calling

> maybe_constant_value before we perform the conversion.


Yup, that worked.

ok?

nathan


-- 
Nathan Sidwell

Comments

Jason Merrill Jan. 4, 2017, 8:58 p.m. UTC | #1
OK.

Jason

On Wed, Jan 4, 2017 at 11:44 AM, Nathan Sidwell <nathan@acm.org> wrote:
> On 01/04/2017 10:13 AM, Jason Merrill wrote:

>

>> OK, that looks like the problem; we shouldn't be calling

>> maybe_constant_value before we perform the conversion.

>

>

> Yup, that worked.

>

>

> ok?

>

> nathan

>

>

> --

> Nathan Sidwell
diff mbox

Patch

2017-01-04  Nathan Sidwell  <nathan@acm.org>

	cp/
	PR c++/78765
	* pt.c (convert_nontype_argument): Don't try and see if integral
	or enum expressions are constants prematurely.

	testsuite/
	PR c++/78765
	* g++.dg/cpp0x/pr78765.C: New.

Index: cp/pt.c
===================================================================
--- cp/pt.c	(revision 244056)
+++ cp/pt.c	(working copy)
@@ -6386,7 +6386,7 @@  convert_nontype_argument (tree type, tre
 	   to leave it in that form rather than lower it to a
 	   CONSTRUCTOR.  */;
       else if (INTEGRAL_OR_ENUMERATION_TYPE_P (type))
-	expr = maybe_constant_value (expr);
+	/* Constant value checking is done later with type conversion.  */;
       else if (cxx_dialect >= cxx1z)
 	{
 	  if (TREE_CODE (type) != REFERENCE_TYPE)
Index: testsuite/g++.dg/cpp0x/pr78765.C
===================================================================
--- testsuite/g++.dg/cpp0x/pr78765.C	(revision 0)
+++ testsuite/g++.dg/cpp0x/pr78765.C	(working copy)
@@ -0,0 +1,15 @@ 
+// PR c++/78765
+// { dg-do compile { target c++11 } }
+
+// ICE with failed constexpr object and member fn call
+
+struct ValueType {
+  constexpr operator int() const {return field;}
+  int field;
+};
+
+static constexpr ValueType var = 0; // { dg-error "conversion" }
+
+template <int> class ValueTypeInfo;
+
+ValueTypeInfo<var> x;