From patchwork Thu Apr 30 16:36:34 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Prathamesh Kulkarni X-Patchwork-Id: 47856 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wi0-f200.google.com (mail-wi0-f200.google.com [209.85.212.200]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 13DBF20553 for ; Thu, 30 Apr 2015 16:36:59 +0000 (UTC) Received: by wizk4 with SMTP id k4sf6352739wiz.2 for ; Thu, 30 Apr 2015 09:36:58 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:mailing-list:precedence:list-id :list-unsubscribe:list-archive:list-post:list-help:sender :delivered-to:mime-version:date:message-id:subject:from:to :content-type:x-original-sender:x-original-authentication-results; bh=5BLP3VHkfPvdCBLQqCEPiqmOoI2cdyOYR44M1Oh8N1I=; b=Lib3DnzU/UDyjfOjWJSf4DuNG+CesAGhiOcyxwc9FJXTt8rHXFj5mjWw4hFJkZBgc5 /816v9XFNrR/bsfe3gGD/T9ylJ1dEsCLaxhy08RdG/LkJLQZk2xx7xK+NV7UgFctwblw 34NuV7yp4spZQyv8LHf5x5FqSiQ+N2rQwPgu8uUAc0yr3aldYj56l89Ffej+8os+rbks F9ReI5D7sM6fB4wIsP1e9FY9/6PSPE872OnjMivGYkPGf5Dh/pcxZT0wLnHOP+Aik9Qs QbSuU++fKxiLQLfXXMAT7Me2Nz8H9A2auF9Ms6hhk5l5UkwatAYjuCgLH3VKIEM64ock G8yA== X-Gm-Message-State: ALoCoQknI5VXtdsXDQU32QcmB6Lf81rS3rQKytmHk50HrCPkTT4yCMdu5Yju/2IgkQoZB7d0gAWw X-Received: by 10.152.87.140 with SMTP id ay12mr3032539lab.8.1430411818356; Thu, 30 Apr 2015 09:36:58 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.22.99 with SMTP id c3ls379983laf.96.gmail; Thu, 30 Apr 2015 09:36:58 -0700 (PDT) X-Received: by 10.112.126.162 with SMTP id mz2mr4514471lbb.97.1430411818212; Thu, 30 Apr 2015 09:36:58 -0700 (PDT) Received: from mail-lb0-x22d.google.com (mail-lb0-x22d.google.com. [2a00:1450:4010:c04::22d]) by mx.google.com with ESMTPS id y1si2127919lae.68.2015.04.30.09.36.57 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 30 Apr 2015 09:36:57 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 2a00:1450:4010:c04::22d as permitted sender) client-ip=2a00:1450:4010:c04::22d; Received: by lbbuc2 with SMTP id uc2so48928111lbb.2 for ; Thu, 30 Apr 2015 09:36:57 -0700 (PDT) X-Received: by 10.112.163.168 with SMTP id yj8mr4665263lbb.36.1430411817638; Thu, 30 Apr 2015 09:36:57 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.67.65 with SMTP id l1csp3222236lbt; Thu, 30 Apr 2015 09:36:56 -0700 (PDT) X-Received: by 10.70.49.229 with SMTP id x5mr9700474pdn.81.1430411815377; Thu, 30 Apr 2015 09:36:55 -0700 (PDT) Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id zz4si4181536pbc.211.2015.04.30.09.36.54 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 30 Apr 2015 09:36:55 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-return-396525-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Received: (qmail 130608 invoked by alias); 30 Apr 2015 16:36:41 -0000 Mailing-List: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: , List-Help: , Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 130590 invoked by uid 89); 30 Apr 2015 16:36:40 -0000 X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.4 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.2 X-HELO: mail-la0-f48.google.com Received: from mail-la0-f48.google.com (HELO mail-la0-f48.google.com) (209.85.215.48) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-GCM-SHA256 encrypted) ESMTPS; Thu, 30 Apr 2015 16:36:39 +0000 Received: by labbd9 with SMTP id bd9so48648056lab.2 for ; Thu, 30 Apr 2015 09:36:36 -0700 (PDT) MIME-Version: 1.0 X-Received: by 10.153.5.36 with SMTP id cj4mr4584077lad.69.1430411795974; Thu, 30 Apr 2015 09:36:35 -0700 (PDT) Received: by 10.25.205.146 with HTTP; Thu, 30 Apr 2015 09:36:34 -0700 (PDT) Date: Thu, 30 Apr 2015 22:06:34 +0530 Message-ID: Subject: [C++ patch] PR 65858 From: Prathamesh Kulkarni To: gcc Patches , paolo.carlini@oracle.com X-IsSubscribed: yes X-Original-Sender: prathamesh.kulkarni@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 2a00:1450:4010:c04::22d as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org; dkim=pass header.i=@gcc.gnu.org X-Google-Group-Id: 836684582541 Hi, The attached patch fixes ICE in PR65858. For the test-case: int x { 0.5 }; int main() { return 0; } Compiling with: g++ -flto -Wno-narrowing -std=gnu++11 results in following ICE: lto1: internal compiler error: in get_constructor, at varpool.c:331 0xd22f73 varpool_node::get_constructor() ../../src/gcc/varpool.c:331 0xd23e28 varpool_node::assemble_decl() ../../src/gcc/varpool.c:602 0x6b8793 output_in_order ../../src/gcc/cgraphunit.c:2137 0x6b8c83 symbol_table::compile() ../../src/gcc/cgraphunit.c:2378 0x62b205 lto_main() ../../src/gcc/lto/lto.c:3496 The ICE happens because error_mark_node gets streamed in the object file and hits the assert: gcc_assert (DECL_INITIAL (decl) != error_mark_node); It appears that r222249, which fixed PR65801 introduced this issue. 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. Conside this part of check_narrowing(): if (!ok) { //... 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; pedwarn() doesn't print warning 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 cxx_dialect is not cxx98 and ok is false, it returns false. The attached patch fixes the ICE, by setting "ok = true" if warn_narrowing is enabled thereby returning "true" to convert_like_real(). Booststrapped and tested on x86_64-unknown-linux-gnu with no regressions. OK for trunk ? Thank you, Prathamesh /cp 2015-04-20 Prathamesh Kulkarni PR c++/65858 * typeck2.c (check_narrowing): Do not pedwarn if -Wno-narrowing is enabled. 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; + } } }