From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-lj1-x230.google.com (mail-lj1-x230.google.com [IPv6:2a00:1450:4864:20::230]) by sourceware.org (Postfix) with ESMTPS id AD07B38432EE for ; Tue, 6 Dec 2022 16:18:55 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org AD07B38432EE Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-lj1-x230.google.com with SMTP id a19so17840837ljk.0 for ; Tue, 06 Dec 2022 08:18:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=OxdGK/LPjUHLqy07uZFBmcFZE1xfhW0ogk0KQGtkf/c=; b=WIGpBYq6S6Z/MTJpTMaiTgw4TGpqApLvOer/Rx1OaaklfokE/R/70Ee41DonXt9la1 B/vB9lQpc7heuWnoQrXQC10EmrS5hrW+FOZph4OvnsyRe8zpwVq+QUy2mu16CbDlRVVS j+LYaXrYyw/jKRRlvE1UKpHaSnGKKWX64W5zyCfeuUPfToU2SE0dol0QBTso44lFb8tM jUStEylWrbnbxQmjhG0woARlzP8bp5eVH8g3TLuk3gQxMO3+H7gS6Z6zDuULj24FgE2F yfbW58pWw+24V90PmEaOkcNOTDt1C4YH63+5KGNRW8aEyoAyYFn9eULQjymsfd7gHQsl AP3A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=OxdGK/LPjUHLqy07uZFBmcFZE1xfhW0ogk0KQGtkf/c=; b=WWU4gJL1ja1SqK4smya7perUDjWmvRIXfGju3tTpyuStgm+w6MPb9mJKYzEkvkwVZu Tf6WP9AWBHDjGv/I14wJtxByQZhJwyDcJvMwjjW2uvHkPW+MXmemzGT3dpAgqIPpG6oH +FIkhR8s5xljXaIYfrUaheLEYLNqeUqIVkqnH5dz2WpETkVoscl1wA52imj5OdxDgjFL Sf339CpAbEoq7X5TFE+w4POi/0X+5Ra0LG/Rak/Zv0S0qVEuKXa8LD31ylE2/65+5OyC tQKCXdUmt6F08UWLOOUPN+Y2R++2OwMpAcoVprrYKyNjO4S3E57FBI4069q+qSNzV2FJ U1Kw== X-Gm-Message-State: ANoB5pngNr+CnYCYBL0MCVS8YrpLjd3fa2HZocWFO0nPwD1HH48zPt93 wgYoJXiAtyU056TDdpA7OxLCMZjt3nfQUtDEP68= X-Google-Smtp-Source: AA0mqf4wAe63QTNRIrH1/mHgCfaf1tWLDDMlu8L62cl0WHbsFX1YUdbMgYJDW9zrry1euECMdD7RhZPJRPlyFDwXaxs= X-Received: by 2002:a2e:8750:0:b0:279:9466:9355 with SMTP id q16-20020a2e8750000000b0027994669355mr15939583ljj.253.1670343534186; Tue, 06 Dec 2022 08:18:54 -0800 (PST) MIME-Version: 1.0 References: <1ba6f0dc-7683-5589-6f88-9f95cab48ed8@ispras.ru> In-Reply-To: <1ba6f0dc-7683-5589-6f88-9f95cab48ed8@ispras.ru> From: Richard Biener Date: Tue, 6 Dec 2022 17:18:41 +0100 Message-ID: Subject: Re: Separate warning/error thresholds for -Wfoo= To: Alexander Monakov Cc: gcc@gcc.gnu.org, David Malcolm Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-0.9 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,KAM_SHORT,RCVD_IN_DNSWL_NONE,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: On Tue, Dec 6, 2022 at 4:53 PM Alexander Monakov via Gcc wrote: > > 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). Implementation-wise one could do a similar trick as we have for global_options vs. global_options_set - add a global_options_error copy (ick!) (and global_options_error_set!?) and have the logic that decides whether a warning is an error pick that set. Of course it's the actual pass that looks at flag_xyz which holds the magic number so that pass would need to be able to see whether it needs to look at both numbers. Btw, does '-Werror=array-bounds=2' imply that =1 kinds are diagnosed as warning? Does it enable -Warray-bounds=2? I think the DWIM behavior isn't all that clear and probably depends on the actual option we want to make it work. Richard. > > 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