From patchwork Tue Jul 3 16:08:01 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Polacek X-Patchwork-Id: 938769 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-480933-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="RXvz5RZt"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 41Kpv40jqlz9s2g for ; Wed, 4 Jul 2018 02:08:15 +1000 (AEST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:subject:message-id:mime-version:content-type; q=dns; s= default; b=IlqRr7dF8wZSS1FCEYkHWMuNt1Rpe3CfmOP/Z6FLbQKwt+q/tKPkf 97H1B2H+ddDPIStgGwNKnuyYTFuQKy5hcaJTmcoAOUBTuuzYAgKNPPGuWRXHq0pD oA4Si+grCqY5xTiAcZent84vvpgjBU8tsSnSRM4MTmEUDlDVqoCqF8= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:subject:message-id:mime-version:content-type; s= default; bh=bavZRglyLM1MCt9qKrgpbcSnzVI=; b=RXvz5RZtP5N1szgb8Oth NykkPhEd2AeIevG/8girbfq0RAemf5FcOUZbksLHa1iK+GjaE/Wrqk+mpLO8pwUg lfgV6Afqmp8fPn+HDOMNheBuYd8nDp8lBtzNwKrmIS/JxjYd6CUM8Pxpo4avOtwe wXMYPeFu9cKwSzL9dIj9EPY= Received: (qmail 38471 invoked by alias); 3 Jul 2018 16:08:07 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk 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 38064 invoked by uid 89); 3 Jul 2018 16:08:06 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-25.3 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_LAZY_DOMAIN_SECURITY, SPF_HELO_PASS autolearn=ham version=3.3.2 spammy= X-HELO: mx1.redhat.com Received: from mx3-rdu2.redhat.com (HELO mx1.redhat.com) (66.187.233.73) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 03 Jul 2018 16:08:05 +0000 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id A79F9EBFEA for ; Tue, 3 Jul 2018 16:08:03 +0000 (UTC) Received: from redhat.com (ovpn-121-59.rdu2.redhat.com [10.10.121.59]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 6C09F1117629; Tue, 3 Jul 2018 16:08:03 +0000 (UTC) Date: Tue, 3 Jul 2018 12:08:01 -0400 From: Marek Polacek To: GCC Patches , Jason Merrill Subject: C++ PATCH for c++/86201, diagnostic routines re-entered crash Message-ID: <20180703160801.GG5927@redhat.com> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.10.0 (2018-05-17) This is an ICE of kind "Error reporting routines re-entered". From the PR: The problem here is that we report the missing return value: 9224 permerror (input_location, "return-statement with no value, in " 9225 "function returning %qT", valtype); but permerror will end up calling print_instantiation_full_context, which ends up calling dump_template_bindings and then tsubst -> tsubst_copy_and_build -> build_functional_cast -> ... -> ocp_convert which has (complain is tf_none) 829 if (complain & tf_warning) 830 return cp_truthvalue_conversion (e); 831 else 832 { 833 /* Prevent bogus -Wint-in-bool-context warnings coming 834 from c_common_truthvalue_conversion down the line. */ 835 warning_sentinel w (warn_int_in_bool_context); 836 return cp_truthvalue_conversion (e); 837 } So we call cp_truthvalue_conversion -> c_common_truthvalue_conversion -> build_binary_op which only calls cp_build_binary_op but with tf_warning_or_error. So even though the warning 4736 if ((complain & tf_warning) 4737 && (FLOAT_TYPE_P (type0) || FLOAT_TYPE_P (type1))) 4738 warning (OPT_Wfloat_equal, 4739 "comparing floating point with == or != is unsafe"); is properly guarded, we still re-enter the diagnostic routines. But since we're parsing decltype we can check c_inhibit_evaluation_warnings which means we won't call warning(). Bootstrapped/regtested on x86_64-linux, ok for trunk? 2018-07-03 Marek Polacek PR c++/86201 * typeck.c (cp_build_binary_op): Check c_inhibit_evaluation_warnings. * g++.dg/diagnostic/pr86201.C: New test. diff --git gcc/cp/typeck.c gcc/cp/typeck.c index 3a4f1cdf479..ea4ce9649cd 100644 --- gcc/cp/typeck.c +++ gcc/cp/typeck.c @@ -4734,6 +4734,7 @@ cp_build_binary_op (location_t location, if (code0 == VECTOR_TYPE && code1 == VECTOR_TYPE) goto vector_compare; if ((complain & tf_warning) + && c_inhibit_evaluation_warnings == 0 && (FLOAT_TYPE_P (type0) || FLOAT_TYPE_P (type1))) warning (OPT_Wfloat_equal, "comparing floating point with == or != is unsafe"); diff --git gcc/testsuite/g++.dg/diagnostic/pr86201.C gcc/testsuite/g++.dg/diagnostic/pr86201.C index e69de29bb2d..e7019c22d95 100644 --- gcc/testsuite/g++.dg/diagnostic/pr86201.C +++ gcc/testsuite/g++.dg/diagnostic/pr86201.C @@ -0,0 +1,12 @@ +// PR c++/86201 +// { dg-do compile { target c++11 } } + +template +auto fn1 (V&& v) -> decltype(U(v)) +{ + return; // { dg-error "return-statement with no value" } +} +void fn2 () +{ + fn1(1.0); +}