From patchwork Fri Dec 2 19:06:01 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [C++] PR 51313 Date: Fri, 02 Dec 2011 09:06:01 -0000 From: Paolo Carlini X-Patchwork-Id: 128936 Message-Id: <4ED92199.4040704@oracle.com> To: "gcc-patches@gcc.gnu.org" Cc: Jason Merrill 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 PR c++/51313 * call.c (null_ptr_cst_p): STRIP_NOPS in c++11 mode too. /testsuite 2011-12-02 Paolo Carlini PR c++/51313 * g++.dg/cpp0x/pr51313.C: New. 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; }