From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail.ispras.ru (mail.ispras.ru [83.149.199.84]) by sourceware.org (Postfix) with ESMTPS id 0167C383FD74 for ; Tue, 6 Dec 2022 15:52:41 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 0167C383FD74 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=ispras.ru Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=ispras.ru Received: from [10.10.3.121] (unknown [10.10.3.121]) by mail.ispras.ru (Postfix) with ESMTPS id 2B0AF40737C3; Tue, 6 Dec 2022 15:52:39 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 mail.ispras.ru 2B0AF40737C3 Date: Tue, 6 Dec 2022 18:52:39 +0300 (MSK) From: Alexander Monakov To: gcc@gcc.gnu.org cc: David Malcolm Subject: Separate warning/error thresholds for -Wfoo= Message-ID: <1ba6f0dc-7683-5589-6f88-9f95cab48ed8@ispras.ru> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII X-Spam-Status: No, score=-3.1 required=5.0 tests=BAYES_00,KAM_DMARC_STATUS,KAM_SHORT,SPF_HELO_NONE,SPF_PASS,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 List-Id: Greetings, David, community, I'd like to get your input on how GCC command line interface should support making a "tiered" warning like -Warray-bounds={1,2} an error for "tier 1" where fewer false positives are expected, and a plain warning otherwise. There was a recent thread mentioning the current limitation [1]: > This also shows nicely why I don't like warnings with levels, what if I want > -Werror=array-bounds=2 + -Warray-bounds=1? Also in PR 48088 [2] there was a request to make it work for stack size usage: > Stumbled on this bug today. I tried to use it in more intricate way: > > -Wframe-larger-than=4096 -Werror=frame-larger-than=32768 > > which would only warn about any stack more than 4096+, but would fail on > 32768+. > > Does it make sense to implement desired behaviour? > I guess it's not many '>=number' style options in gcc. A problem with implementing DWIM semantics like above for -Wfoo=k -Werror=foo=n combination is that technically it changes its current meaning. If we don't want to risk that, an alternative is to introduce a new option for selecting error threshold for a tiered warning, for example: -Warray-bounds=2 -Werror-level=array-bounds=1 Implementation-wise, we would need to extend common.opt language to annotate which tier is more inclusive (generally smaller 'n' means fewer warnings, but for -Wstack-usage and -Wstrict-aliasing it's the other way around). Opinions? Does anybody envision problems with going the DWIM way? Thanks. Alexander [1] https://inbox.sourceware.org/gcc-patches/2552ab22-916f-d0fe-2c78-d482f6ad8412@lauterbach.com/ [2] https://gcc.gnu.org/bugzilla/show_bug.cgi?id=48088#c5