From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 130608 invoked by alias); 30 Apr 2015 16:36:41 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 130590 invoked by uid 89); 30 Apr 2015 16:36:40 -0000 Authentication-Results: sourceware.org; auth=none 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) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:date:message-id:subject:from:to :content-type; bh=KWHiz8KFcPdUhz44kPuqiWQIGSlM6/yPoauTDOW54nw=; b=Wqpm9o0cCjKJniU0KI0Lfz8XTNv7px1pXmj9Jgn0XjLHO3sq2w+Olho0dwgLWgFdZy NcAeLl8uKT2n4FkkafwwvmPul76kXWBYE3C7F6W5dj6vSZ92yzWMXgHfoeQds7ai2xZ3 SF5QvjydALwI4STeCNw2kEXxmctFzsWvNmffub2kuLWWXgPe0O2Y7SutGPMtKnAvyt1Q u5cPsvlZWji6L5OreDTCd7LBlMij5vpq93HqMDiSpxShN/Oxcmc1I0YXvkuabjd3KBIG 4UNhgrII5VnlVIKKMVxltO1SbatMzlPFcfXrWm/BFnYdr3X696iALtOMLi2ZOxuuY9mc cVBg== X-Gm-Message-State: ALoCoQkCOEqNRAJHxx/AgQ6a7p1QodIPCII2nGMazZhDC5U+w1NcL4/Eu9zzj9k4OOruTUD4krKh 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 17:21:00 -0000 Message-ID: Subject: [C++ patch] PR 65858 From: Prathamesh Kulkarni To: gcc Patches , paolo.carlini@oracle.com Content-Type: multipart/mixed; boundary=001a1135e70cfbebeb0514f3b2a0 X-IsSubscribed: yes X-SW-Source: 2015-04/txt/msg02065.txt.bz2 --001a1135e70cfbebeb0514f3b2a0 Content-Type: text/plain; charset=UTF-8 Content-length: 2357 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 --001a1135e70cfbebeb0514f3b2a0 Content-Type: text/plain; charset=US-ASCII; name="ChangeLog.txt" Content-Disposition: attachment; filename="ChangeLog.txt" Content-Transfer-Encoding: base64 X-Attachment-Id: f_i94e5gom1 Content-length: 224 L2NwCjIwMTUtMDQtMjAgIFByYXRoYW1lc2ggS3Vsa2FybmkgIDxwcmF0aGFt ZXNoLmt1bGthcm5pQGxpbmFyby5vcmc+CgkKCVBSIGMrKy82NTg1OAoJKiB0 eXBlY2syLmMgKGNoZWNrX25hcnJvd2luZyk6IERvIG5vdCBwZWR3YXJuIGlm IC1Xbm8tbmFycm93aW5nIGlzIGVuYWJsZWQuCg== --001a1135e70cfbebeb0514f3b2a0 Content-Type: text/x-patch; charset=US-ASCII; name="65858.patch" Content-Disposition: attachment; filename="65858.patch" Content-Transfer-Encoding: base64 X-Attachment-Id: f_i94e5gnx0 Content-length: 1212 SW5kZXg6IGdjYy9jcC90eXBlY2syLmMKPT09PT09PT09PT09PT09PT09PT09 PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09 PQotLS0gZ2NjL2NwL3R5cGVjazIuYwkocmV2aXNpb24gMjIyNTczKQorKysg Z2NjL2NwL3R5cGVjazIuYwkod29ya2luZyBjb3B5KQpAQCAtOTU4LDExICs5 NTgsMTcgQEAKIAl9CiAgICAgICBlbHNlIGlmIChjb21wbGFpbiAmIHRmX2Vy cm9yKQogCXs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