public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "prathamesh3492 at gcc dot gnu.org" <gcc-bugzilla@gcc.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	[thread overview]
Message-ID: <bug-65858-4-oR5bFrF9PA@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-65858-4@http.gcc.gnu.org/bugzilla/>

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65858

--- 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=gnu++11 -flto --param lto-partitions=1
> Full command line options: http://pastebin.com/6JSWH9YM
> 
> ../../third_party/cld_2/src/internal/cld_generated_cjk_uni_prop_80.cc:7132: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
> 
> Reduced test-case:
> It appears that r222249, which fixed PR65801 introduced this issue. 
> The following test-case also ICE's for x86.
> 
> int x { 0.5 };
> int main() { return 0; }
> 
> prathamesh.kulkarni@ex40-01:~$ fsf-toolchain/bin/g++ -flto braced-init.cpp
> -c -Wno-narrowing -std=gnu++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
> 
> I think it happens because, check_narrowing() returns false and it's caller
> cp/semantics.c:finish_compound_literal 
> returns error_mark_node, which then gets streamed into object file.
> 
> Conside this part of check_narrowing():
> 
> if (!ok)
>     {
>       if (cxx_dialect == cxx98)
>         warning_at (EXPR_LOC_OR_LOC (init, input_location), OPT_Wnarrowing,
>                     "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 = true;
>             }
>         }
>       else if (complain & tf_error)
>         {
>           global_dc->pedantic_errors = 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 = flag_pedantic_errors;
>         }
>     }
> 
> return cxx_dialect == cxx98 || ok;
> 
> For the above test-case ok is false and we enter the nested
> else if (complain & tf_error) block.
> 
> 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;
> 
> So diagnostic_report_diagnostic() returns false to pedwarn()
> which then returns 0 to check_narrowing() and warning is not printed.
> 
> return cxx_dialect == cxx98 || ok;
> Since we are compiling with gnu++11 mode, cxx_dialect
> is not cxx98 and ok is false, hence check_narrowing() returns false.
> 
> 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;
> 
> 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
===================================================================
--- 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 = 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 = flag_pedantic_errors;
+         /* silence warning if -Wno-narrowing -is specified */
+         if (!warn_narrowing)
+           ok = true;
+         else
+           { 
+             global_dc->pedantic_errors = 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 = flag_pedantic_errors;
+           }
        }
     }

Thank you,
Prathamesh
> 
> 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 = true;
>    REAL_VALUE_TYPE d;
> 
> -  if (((!warn_narrowing || !(complain & tf_warning))
> -       && cxx_dialect == cxx98)
> +  if ((!warn_narrowing || !(complain & tf_warning))
>        || !ARITHMETIC_TYPE_P (type))
>      return ok;
> 
> Since we want -Wno-narrowing to also silence C++11 stricter
> narrowing rules (PR65801), I removed condition on cxx_dialect == cxx98.
> 
> 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: <gcc-bugs-return-485117-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org>
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: <gcc-bugs.gcc.gnu.org>
List-Archive: <http://gcc.gnu.org/ml/gcc-bugs/>
List-Post: <mailto:gcc-bugs@gcc.gnu.org>
List-Help: <mailto:gcc-bugs-help@gcc.gnu.org>
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" <gcc-bugzilla@gcc.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: <bug-65801-4-tWuQrXerXd@http.gcc.gnu.org/bugzilla/>
In-Reply-To: <bug-65801-4@http.gcc.gnu.org/bugzilla/>
References: <bug-65801-4@http.gcc.gnu.org/bugzilla/>
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?ide801

--- Comment #21 from paolo at gcc dot gnu.org <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"2636&root=gcc&view=rev
Log:
/cp
2015-04-30  Paolo Carlini  <paolo.carlini@oracle.com>

        PR c++/65801
        * typeck2.c (check_narrowing): In C++11 mode too, -Wno-narrowing
        suppresses the diagnostic.

2015-04-30  Paolo Carlini  <paolo.carlini@oracle.com>

        PR c++/65801
        * doc/invoke.texi ([-Wnarrowing]): Update.

/testsuite
2015-04-30  Paolo Carlini  <paolo.carlini@oracle.com>

        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


  parent reply	other threads:[~2015-04-30 16:22 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <bug-65858-4@http.gcc.gnu.org/bugzilla/>
2015-04-23 16:37 ` hubicka at gcc dot gnu.org
2015-04-27 15:47 ` prathamesh3492 at gcc dot gnu.org
2015-04-30 16:22 ` prathamesh3492 at gcc dot gnu.org [this message]
2015-04-30 19:48 ` [Bug c++/65858] [5/6 Regression] " paolo.carlini at oracle dot com
2015-05-01 18:44 ` paolo at gcc dot gnu.org
2015-05-01 18:48 ` paolo at gcc dot gnu.org
2015-05-01 18:55 ` paolo.carlini at oracle dot com
2015-05-01 22:00 ` prathamesh3492 at gcc dot gnu.org

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-65858-4-oR5bFrF9PA@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).