From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 80767 invoked by alias); 30 Apr 2015 16:22:48 -0000 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org Received: (qmail 80689 invoked by uid 48); 30 Apr 2015 16:22:43 -0000 From: "prathamesh3492 at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug ipa/65858] ICE in varpool_node::get_constructor during chromium build on arm-linux-gnueabihf with LTO during LINK chrome Date: Thu, 30 Apr 2015 16:22:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: ipa X-Bugzilla-Version: 6.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: prathamesh3492 at gcc dot gnu.org X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-SW-Source: 2015-04/txt/msg02668.txt.bz2 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D65858 --- Comment #3 from prathamesh3492 at gcc dot gnu.org --- (In reply to prathamesh3492 from comment #2) > Hi, > Sorry for late response, I applied your patch and got the following ICE: > -std=3Dgnu++11 -flto --param lto-partitions=3D1 > Full command line options: http://pastebin.com/6JSWH9YM >=20 > ../../third_party/cld_2/src/internal/cld_generated_cjk_uni_prop_80.cc:713= 2:1: > internal compiler error: in output_constructor, at lto-streamer-out.c:2152 > } // End namespace CLD2 > ^ > 0xb25609 output_constructor > /home/prathamesh.kulkarni/gnu-toolchain/src/gcc.git/gcc/lto-streamer-out= .c: > 2152 > 0xb25609 lto_output() > /home/prathamesh.kulkarni/gnu-toolchain/src/gcc.git/gcc/lto-streamer-out= .c: > 2354 > 0xb7e6c1 write_lto > /home/prathamesh.kulkarni/gnu-toolchain/src/gcc.git/gcc/passes.c:2395 > 0xb81c0e ipa_write_summaries_1 > /home/prathamesh.kulkarni/gnu-toolchain/src/gcc.git/gcc/passes.c:2459 > 0xb81c0e ipa_write_summaries() > /home/prathamesh.kulkarni/gnu-toolchain/src/gcc.git/gcc/passes.c:2519 > 0x877dda ipa_passes > /home/prathamesh.kulkarni/gnu-toolchain/src/gcc.git/gcc/cgraphunit.c:2216 > 0x877dda symbol_table::compile() > /home/prathamesh.kulkarni/gnu-toolchain/src/gcc.git/gcc/cgraphunit.c:2312 > 0x879d3c symbol_table::finalize_compilation_unit() > /home/prathamesh.kulkarni/gnu-toolchain/src/gcc.git/gcc/cgraphunit.c:2461 > 0x645c40 cp_write_global_declarations() > /home/prathamesh.kulkarni/gnu-toolchain/src/gcc.git/gcc/cp/decl2.c:4757 >=20 > Reduced test-case: > It appears that r222249, which fixed PR65801 introduced this issue.=20 > The following test-case also ICE's for x86. >=20 > int x { 0.5 }; > int main() { return 0; } >=20 > prathamesh.kulkarni@ex40-01:~$ fsf-toolchain/bin/g++ -flto braced-init.cpp > -c -Wno-narrowing -std=3Dgnu++11 > prathamesh.kulkarni@ex40-01:~$ fsf-toolchain/bin/g++ -flto braced-init.o > lto1: internal compiler error: in get_constructor, at varpool.c:331 > 0xd22c43 varpool_node::get_constructor() > ../../src/gcc/varpool.c:331 > 0xd23af8 varpool_node::assemble_decl() > ../../src/gcc/varpool.c:602 > 0x6b8633 output_in_order > ../../src/gcc/cgraphunit.c:2137 > 0x6b8b23 symbol_table::compile() > ../../src/gcc/cgraphunit.c:2378 > 0x62b025 lto_main() > ../../src/gcc/lto/lto.c:3496 >=20 > I think it happens because, check_narrowing() returns false and it's call= er > cp/semantics.c:finish_compound_literal=20 > returns error_mark_node, which then gets streamed into object file. >=20 > Conside this part of check_narrowing(): >=20 > if (!ok) > { > if (cxx_dialect =3D=3D cxx98) > warning_at (EXPR_LOC_OR_LOC (init, input_location), OPT_Wnarrowin= g, > "narrowing conversion of %qE from %qT to %qT inside {= } " > "is ill-formed in C++11", init, ftype, type); > else if (!TREE_CONSTANT (init)) > { > if (complain & tf_warning_or_error) > { > pedwarn (EXPR_LOC_OR_LOC (init, input_location), > OPT_Wnarrowing, > "narrowing conversion of %qE from %qT to %qT inside= { > }", > init, ftype, type); > ok =3D true; > } > } > else if (complain & tf_error) > { > global_dc->pedantic_errors =3D 1; > pedwarn (EXPR_LOC_OR_LOC (init, input_location), OPT_Wnarrowing, > "narrowing conversion of %qE from %qT to %qT inside { = }", > init, ftype, type); > global_dc->pedantic_errors =3D flag_pedantic_errors; > } > } >=20 > return cxx_dialect =3D=3D cxx98 || ok; >=20 > For the above test-case ok is false and we enter the nested > else if (complain & tf_error) block. >=20 > pedwarn() doesn't print anything here and returns 0. > That's because the following condition becomes true in > diagnostic.c:diagnostic_report_diagnostic(): > /* This tests if the user provided the appropriate -Wfoo or > -Wno-foo option. */ > if (! context->option_enabled (diagnostic->option_index, > context->option_state)) > return false; >=20 > So diagnostic_report_diagnostic() returns false to pedwarn() > which then returns 0 to check_narrowing() and warning is not printed. >=20 > return cxx_dialect =3D=3D cxx98 || ok; > Since we are compiling with gnu++11 mode, cxx_dialect > is not cxx98 and ok is false, hence check_narrowing() returns false. >=20 > cp/semantics.c:finish_compound_literal() calls check_narrowing(): > if (SCALAR_TYPE_P (type) > && !BRACE_ENCLOSED_INITIALIZER_P (compound_literal) > && !check_narrowing (type, compound_literal, complain)) > return error_mark_node; >=20 > I suppose that check_narrowing() returns false here and the above if > condition becomes true and finish_compound_literal() returns > error_mark_node which is then streamed. Is that correct ? This part was wrong. For the above test-case convert_like_real() calls check_narrowing(): if (convs->check_narrowing && !check_narrowing (totype, expr, complain)) return error_mark_node; Here convert_like_real() returns error_mark_node, because check_narrowing() returns false for the above test-case. The following patch fixes the ICE. Bootstrapped and tested on x86_64-unknown-linux-gnu: Index: gcc/cp/typeck2.c =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- gcc/cp/typeck2.c (revision 222573) +++ gcc/cp/typeck2.c (working copy) @@ -958,11 +958,17 @@ } else if (complain & tf_error) { - global_dc->pedantic_errors =3D 1; - pedwarn (EXPR_LOC_OR_LOC (init, input_location), OPT_Wnarrowing, - "narrowing conversion of %qE from %qT to %qT inside { }", - init, ftype, type); - global_dc->pedantic_errors =3D flag_pedantic_errors; + /* silence warning if -Wno-narrowing -is specified */ + if (!warn_narrowing) + ok =3D true; + else + {=20 + global_dc->pedantic_errors =3D 1; + pedwarn (EXPR_LOC_OR_LOC (init, input_location), OPT_Wnarrowi= ng, + "narrowing conversion of %qE from %qT to %qT inside {= }", + init, ftype, type); + global_dc->pedantic_errors =3D flag_pedantic_errors; + } } } Thank you, Prathamesh >=20 > I tried with the following untested patch, which prevents the ICE, > but not sure if it's the right approach: > diff --git a/gcc/cp/typeck2.c b/gcc/cp/typeck2.c > index 884957b..2a25c20 100644 > --- a/gcc/cp/typeck2.c > +++ b/gcc/cp/typeck2.c > @@ -872,8 +872,7 @@ check_narrowing (tree type, tree init, tsubst_flags_t > complain) > bool ok =3D true; > REAL_VALUE_TYPE d; >=20 > - if (((!warn_narrowing || !(complain & tf_warning)) > - && cxx_dialect =3D=3D cxx98) > + if ((!warn_narrowing || !(complain & tf_warning)) > || !ARITHMETIC_TYPE_P (type)) > return ok; >=20 > Since we want -Wno-narrowing to also silence C++11 stricter > narrowing rules (PR65801), I removed condition on cxx_dialect =3D=3D cxx9= 8. >=20 > Thank you, > Prathamesh >>From gcc-bugs-return-485117-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Thu Apr 30 16:32:16 2015 Return-Path: Delivered-To: listarch-gcc-bugs@gcc.gnu.org Received: (qmail 122170 invoked by alias); 30 Apr 2015 16:32:15 -0000 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org Delivered-To: mailing list gcc-bugs@gcc.gnu.org Received: (qmail 121388 invoked by uid 55); 30 Apr 2015 16:32:11 -0000 From: "paolo at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/65801] [5/6 Regression] Allow -Wno-narrowing to silence stricter C++11 narrowing rules Date: Thu, 30 Apr 2015 16:32:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c++ X-Bugzilla-Version: 5.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: enhancement X-Bugzilla-Who: paolo at gcc dot gnu.org X-Bugzilla-Status: NEW X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-SW-Source: 2015-04/txt/msg02669.txt.bz2 Content-length: 1018 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65801 --- Comment #21 from paolo at gcc dot gnu.org --- Author: paolo Date: Thu Apr 30 16:31:36 2015 New Revision: 222636 URL: https://gcc.gnu.org/viewcvs?rev=222636&root=gcc&view=rev Log: /cp 2015-04-30 Paolo Carlini PR c++/65801 * typeck2.c (check_narrowing): In C++11 mode too, -Wno-narrowing suppresses the diagnostic. 2015-04-30 Paolo Carlini PR c++/65801 * doc/invoke.texi ([-Wnarrowing]): Update. /testsuite 2015-04-30 Paolo Carlini PR c++/65801 * g++.dg/cpp0x/Wnarrowing2.C: New. Added: branches/gcc-5-branch/gcc/testsuite/g++.dg/cpp0x/Wnarrowing2.C Modified: branches/gcc-5-branch/gcc/ChangeLog branches/gcc-5-branch/gcc/cp/ChangeLog branches/gcc-5-branch/gcc/cp/typeck2.c branches/gcc-5-branch/gcc/doc/invoke.texi branches/gcc-5-branch/gcc/testsuite/ChangeLog