From patchwork Thu Aug 1 20:20:38 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Polacek X-Patchwork-Id: 1968007 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=bH+zaNH3; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=server2.sourceware.org; envelope-from=gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=patchwork.ozlabs.org) Received: from server2.sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4WZgMt6c0cz1ybX for ; Fri, 2 Aug 2024 06:21:14 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 33170385C6C3 for ; Thu, 1 Aug 2024 20:21:13 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTP id 597C13858C53 for ; Thu, 1 Aug 2024 20:20:45 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 597C13858C53 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 597C13858C53 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1722543649; cv=none; b=wrlcuCF4g1+G15YV0GWmdYAJfme5zpQvA9GYIU4Ia5McFfvNOVr670bFeAY+ZWA3VMJDZj0B5HzWm4Mcj7wOKfrSIY/H5H5RrGOrdbJqsOAQxQ6lsJgPbfQ1YPDJ8jtJXKPLertel89VhbupeXerLxJPY/Mc3K714/y0COH327I= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1722543649; c=relaxed/simple; bh=KBZ5S3im3dWycOiDP9QUd+ionoWZDm7SBa9Hoz/zOS0=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=sAe2IZy+EAtqqSbNrJJIuwvQzw6N/jftsSrBTW1WTT7cmihgViZisByFkSf5FjDnx/YcM2ShtRCO/IgMQm4O6vllLT1N4a3rDwVNr/jKOfAmGh/Ym2I/dsOmmBDj8eORliAsByExxTP9SzWxStwkOZqiu9lcFfUNfgtIYrsjEjg= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1722543645; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=iu6QkCuREAmTeohKUGOPGE5q2tH4UtJR71bLqiF2LhA=; b=bH+zaNH3FNkhunClBP9y6t1//yBfnXP3bIa7JXk2cFaJB/XE9nkR8nrKM/KIB5iB2ev1wl 0SBOrKjbnJeJdjNzNthooJgU4VAUXMGm1oGrJGVFSjl8cF67c4q5sIe3oUqdRj/cP8qy3b GNu7SgTPlqi/lU1d+ce41njOvehQOsg= Received: from mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-680-LJqL1Aq8NLaPpnWo4IrvFQ-1; Thu, 01 Aug 2024 16:20:42 -0400 X-MC-Unique: LJqL1Aq8NLaPpnWo4IrvFQ-1 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 97B251955D4B for ; Thu, 1 Aug 2024 20:20:41 +0000 (UTC) Received: from pdp-11.redhat.com (unknown [10.22.16.66]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id C0ED11955E70; Thu, 1 Aug 2024 20:20:40 +0000 (UTC) From: Marek Polacek To: GCC Patches , Jason Merrill Subject: [PATCH] c++: Move -Wdangling-reference to -Wextra Date: Thu, 1 Aug 2024 16:20:38 -0400 Message-ID: <20240801202038.3945271-1-polacek@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.17 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-12.3 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org Bootstrapped/regtested on x86_64-pc-linux-gnu, ok for trunk? -- >8 -- Despite a number of mitigations (don't warn for std::span-like classes, lambdas, adding [[gnu::no_dangling]], etc.), the warning still seems to cause some grief. Let's move the warning to -Wextra, then. gcc/c-family/ChangeLog: * c.opt (Wdangling-reference): Move from -Wall to -Wextra. gcc/ChangeLog: * doc/invoke.texi: Document that -Wdangling-reference is enabled by -Wextra. --- gcc/c-family/c.opt | 2 +- gcc/doc/invoke.texi | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) base-commit: 32e678b2ed752154b2f96719e33f11a7c6417f20 diff --git a/gcc/c-family/c.opt b/gcc/c-family/c.opt index a52682d835c..979f17a7e32 100644 --- a/gcc/c-family/c.opt +++ b/gcc/c-family/c.opt @@ -604,7 +604,7 @@ C ObjC C++ ObjC++ Joined RejectNegative UInteger Var(warn_dangling_pointer) Warn Warn for uses of pointers to auto variables whose lifetime has ended. Wdangling-reference -C++ ObjC++ Var(warn_dangling_reference) Warning LangEnabledBy(C++ ObjC++, Wall) +C++ ObjC++ Var(warn_dangling_reference) Warning LangEnabledBy(C++ ObjC++, Wextra) Warn when a reference is bound to a temporary whose lifetime has ended. Wdate-time diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi index ef2213b4e84..252b232e9f2 100644 --- a/gcc/doc/invoke.texi +++ b/gcc/doc/invoke.texi @@ -3962,7 +3962,7 @@ that has a pointer data member and a trivial destructor. The warning can be disabled by using the @code{gnu::no_dangling} attribute (@pxref{C++ Attributes}). -This warning is enabled by @option{-Wall}. +This warning is enabled by @option{-Wextra}. @opindex Wdelete-non-virtual-dtor @opindex Wno-delete-non-virtual-dtor @@ -6481,6 +6481,7 @@ name is still supported, but the newer name is more descriptive.) -Wcalloc-transposed-args -Wcast-function-type -Wclobbered +-Wdangling-reference @r{(C++ only)} -Wdeprecated-copy @r{(C++ and Objective-C++ only)} -Wempty-body -Wenum-conversion @r{(only for C/ObjC)}