From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gate.crashing.org (gate.crashing.org [63.228.1.57]) by sourceware.org (Postfix) with ESMTP id 4CE063858D32 for ; Mon, 30 Jan 2023 23:11:01 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 4CE063858D32 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=kernel.crashing.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=kernel.crashing.org Received: from gate.crashing.org (localhost.localdomain [127.0.0.1]) by gate.crashing.org (8.14.1/8.14.1) with ESMTP id 30UNA0j7021963; Mon, 30 Jan 2023 17:10:00 -0600 Received: (from segher@localhost) by gate.crashing.org (8.14.1/8.14.1/Submit) id 30UNA0df021960; Mon, 30 Jan 2023 17:10:00 -0600 X-Authentication-Warning: gate.crashing.org: segher set sender to segher@kernel.crashing.org using -f Date: Mon, 30 Jan 2023 17:09:59 -0600 From: Segher Boessenkool To: Patrick Herbst Cc: gcc-help Subject: Re: how does -Wstringop-truncation work? Message-ID: <20230130230959.GW25951@gate.crashing.org> References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.4.2.3i X-Spam-Status: No, score=-3.0 required=5.0 tests=BAYES_00,JMQ_SPF_NEUTRAL,KAM_DMARC_STATUS,SPF_HELO_PASS,SPF_PASS,TXREP autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: On Mon, Jan 30, 2023 at 05:35:39PM -0500, Patrick Herbst via Gcc-help wrote: > I can get the warning to display if running > gcc -Wall -02 > > I can even get it to display if running > gcc -Wall -O1 -foptimize-strlen > > but i cannot get it to display if not using optimization. The manual says The effectiveness of some warnings depends on optimizations also being enabled. For example '-Wsuggest-final-types' is more effective with link-time optimization and some instances of other warnings may not be issued at all unless optimization is enabled. While optimization in general improves the efficacy of control and data flow sensitive warnings, in some cases it may also cause false positives. > I've even > tried manually adding all the -f options documented for -O1 to > understand what other flags might be needed to generate the warning. Flags like -O1 do more than just enabling some other flags. Segher