From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 80644 invoked by alias); 17 Jan 2019 21:17:34 -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 80212 invoked by uid 89); 17 Jan 2019 21:17:34 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-0.4 required=5.0 tests=BAYES_00,KAM_LAZY_DOMAIN_SECURITY,KAM_NUMSUBJECT,RCVD_IN_DNSWL_NONE autolearn=no version=3.3.2 spammy=trees, Hx-languages-length:1265 X-HELO: mail-qt1-f177.google.com Received: from mail-qt1-f177.google.com (HELO mail-qt1-f177.google.com) (209.85.160.177) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 17 Jan 2019 21:17:32 +0000 Received: by mail-qt1-f177.google.com with SMTP id y20so12934736qtm.13 for ; Thu, 17 Jan 2019 13:17:32 -0800 (PST) Return-Path: Received: from [192.168.1.115] (209-6-216-142.s141.c3-0.smr-cbr1.sbo-smr.ma.cable.rcncustomer.com. [209.6.216.142]) by smtp.gmail.com with ESMTPSA id w13sm26651781qkj.8.2019.01.17.13.17.29 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 17 Jan 2019 13:17:30 -0800 (PST) Subject: Re: C++ PATCH for c++/78244 - narrowing conversion in template not detected, part 2 To: Marek Polacek , GCC Patches References: <20190117190921.GM19569@redhat.com> From: Jason Merrill Message-ID: <4958169a-e8c8-4ca0-6f99-ce360b4834d5@redhat.com> Date: Thu, 17 Jan 2019 21:17:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.3.1 MIME-Version: 1.0 In-Reply-To: <20190117190921.GM19569@redhat.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-IsSubscribed: yes X-SW-Source: 2019-01/txt/msg01031.txt.bz2 On 1/17/19 2:09 PM, Marek Polacek wrote: > This patch ought to fix the rest of 78244, a missing narrowing warning in > decltype. > > As I explained in Bugzilla, there can be three scenarios: > > 1) decltype is in a template and it has no dependent expressions, which > is the problematical case. finish_compound_literal just returns the > compound literal without checking narrowing if processing_template_decl. This is the sort of thing that we've been gradually fixing: if the compound literal isn't dependent at all, we want to do the normal processing. And then usually return a result based on the original trees rather than the result of processing. For instance, finish_call_expr. Something like that ought to work here, too, and be more generally applicable; this shouldn't be limited to casting to a scalar type, casting to a known class type can also involve narrowing. The check in the other patch that changes instantiation_dependent_r should be more similar to the one in finish_compound_literal. Or perhaps you could set a flag here in finish_compound_literal to indicate that it's instantiation-dependent, and just check that in instantiation_dependent_r. Jason