public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Martin Sebor <msebor@gmail.com>
To: Jakub Jelinek <jakub@redhat.com>
Cc: Richard Biener <richard.guenther@gmail.com>,
	GCC Patches <gcc-patches@gcc.gnu.org>
Subject: Re: [PATCH] treat -Wxxx-larger-than=HWI_MAX special (PR 86631)
Date: Wed, 25 Jul 2018 15:54:00 -0000	[thread overview]
Message-ID: <3a5817e7-b766-3183-d119-f21bf6fbb838@gmail.com> (raw)
In-Reply-To: <20180725145724.GR17988@tucnak>

On 07/25/2018 08:57 AM, Jakub Jelinek wrote:
> On Wed, Jul 25, 2018 at 08:54:13AM -0600, Martin Sebor wrote:
>> I don't mean for the special value to be used except internally
>> for the defaults.  Otherwise, users wanting to override the default
>> will choose a value other than it.  I'm happy to document it in
>> the .opt file for internal users though.
>>
>> -1 has the documented effect of disabling the warnings altogether
>> (-1 is SIZE_MAX) so while I agree that -1 looks better it doesn't
>> work.  (It would need more significant changes.)
>
> The variable is signed, so -1 is not SIZE_MAX.  Even if -1 disables it, you
> could use e.g. -2 or other negative value for the other special case.

The -Wxxx-larger-than=N distinguish three ranges of argument
values (treated as unsigned):

   1.  [0, HOST_WIDE_INT_MAX)
   2.  HOST_WIDE_INT_MAX
   3.  [HOST_WIDE_INT_MAX + 1, Infinity)

(1) implies warnings for allocations in excess of the size.  For
the alloca/VLA warnings it also means warnings for allocations
that may be unbounded.  (This feels like a bit of a wart.)

(2) implies warnings for allocations in excess of PTRDIFF_MAX
only.  For the alloca/VLA warnings it also disables warnings
for allocations that may be unbounded (also a bit of a wart)

(3) isn't treated consistently by all options (yet) but for
the alloca/VLA warnings it means no warnings.  Since
the argument value is stored in signed HOST_WIDE_INT this
range is strictly negative.

Any value from (3) could in theory be made special and used
instead of -1 or HOST_WIDE_INT_MAX as a placeholder for
PTRDIFF_MAX.  But no matter what the choice is, it removes
the value from the usable set in (3) (i.e., it doesn't have
the expected effect of disabling the warning).

I don't see the advantage of picking -2 over any other negative
number.  As inelegant as the current choice of HOST_WIDE_INT_MAX
may be, it seems less arbitrary and less intrusive than picking
a random value from the negative range.

Martin

PS The handling of these ranges isn't consistent across all
the options because they were each developed independently
and without necessarily aiming for it.  I think making them
more consistent would be nice as a followup patch.  I would
expect consistency to be achievable more easily if baking
special cases into the design is kept to a minimum.  It
would also help to remove some existing special cases.
E.g., by introducing a distinct option for the special case
of diagnosing unbounded alloca/VLA allocations and removing
it from -W{alloca,vla}-larger-than=.

  reply	other threads:[~2018-07-25 15:54 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-07-25  2:07 Martin Sebor
2018-07-25  8:34 ` Richard Biener
2018-07-25 14:54   ` Martin Sebor
2018-07-25 14:57     ` Jakub Jelinek
2018-07-25 15:54       ` Martin Sebor [this message]
2018-07-26  8:39         ` Richard Biener
2018-07-26 14:59           ` Martin Sebor
2018-07-26 20:52             ` Martin Sebor
2018-08-02  3:25               ` PING " Martin Sebor
2018-08-02 16:34                 ` Joseph Myers
2018-08-20 12:14               ` Richard Biener
2018-08-22 22:20                 ` Martin Sebor
2018-08-23 13:18                   ` Richard Biener
2018-08-23 22:35                     ` Martin Sebor
2018-08-24  9:36                       ` Richard Biener
2018-08-24 15:13                         ` Martin Sebor
2018-08-28  2:37                           ` Martin Sebor
2018-08-28  9:46                             ` Richard Biener

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=3a5817e7-b766-3183-d119-f21bf6fbb838@gmail.com \
    --to=msebor@gmail.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=jakub@redhat.com \
    --cc=richard.guenther@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).