Patchwork [C++] PR 51313

login
register
mail settings
Submitter Paolo Carlini
Date Dec. 2, 2011, 7:06 p.m.
Message ID <4ED92199.4040704@oracle.com>
Download mbox | patch
Permalink /patch/128936/
State New
Headers show

Comments

Paolo Carlini - Dec. 2, 2011, 7:06 p.m.
Hi,

here we ICE in C++11 mode in null_ptr_cst_p because integer_zerop is 
true for a NOP_EXPR, which TREE_OVERFLOW cannot handle. Thus the idea is 
using STRIP_NOPS in C++11 mode too: makes sense to me unless we have 
reasons of principle to exclude NOPs in that mode. Anyway, patch passes 
testing on x86_64-linux.

Thanks,
Paolo.

///////////////////////
/cp
2011-12-02  Paolo Carlini  <paolo.carlini@oracle.com>

	PR c++/51313
	* call.c (null_ptr_cst_p): STRIP_NOPS in c++11 mode too.

/testsuite
2011-12-02  Paolo Carlini  <paolo.carlini@oracle.com>

	PR c++/51313
	* g++.dg/cpp0x/pr51313.C: New.
Jason Merrill - Dec. 3, 2011, 1:23 p.m.
OK.

Jason

Patch

Index: testsuite/g++.dg/cpp0x/pr51313.C
===================================================================
--- testsuite/g++.dg/cpp0x/pr51313.C	(revision 0)
+++ testsuite/g++.dg/cpp0x/pr51313.C	(revision 0)
@@ -0,0 +1,18 @@ 
+// PR c++/51313
+// { dg-options "-std=c++0x" }
+
+class ostream;
+
+extern "C" {
+  extern int isdigit (int);
+}
+
+ostream&
+operator<<(ostream&, const unsigned char*);
+
+extern ostream cout;
+
+int main()
+{
+  cout << isdigit(0);
+}
Index: cp/call.c
===================================================================
--- cp/call.c	(revision 181932)
+++ cp/call.c	(working copy)
@@ -549,10 +549,8 @@  null_ptr_cst_p (tree t)
     {
       /* Core issue 903 says only literal 0 is a null pointer constant.  */
       if (cxx_dialect < cxx0x)
-	{
-	  t = integral_constant_value (t);
-	  STRIP_NOPS (t);
-	}
+	t = integral_constant_value (t);
+      STRIP_NOPS (t);
       if (integer_zerop (t) && !TREE_OVERFLOW (t))
 	return true;
     }