This is the mail archive of the
mailing list for the GCC project.
Re: [PATCH] treat -Wxxx-larger-than=HWI_MAX special (PR 86631)
On 07/25/2018 02:34 AM, Richard Biener wrote:
On Wed, Jul 25, 2018 at 4:07 AM Martin Sebor <firstname.lastname@example.org> wrote:
The very large option argument enhancement committed last week
inadvertently introduced an assumption about the LP64 data model
that makes the -Wxxx-larger-than options have a different effect
at their default documented setting of PTRDIFF_MAX between ILP32
and LP64. As a result, the options are treated as suppressed in
ILP32 while triggering the expected warnings for allocations or
sizes in excess of the limit in ILP64.
To remove this I considered making it possible to use symbolic
constants like PTRDIFF_MAX as the option arguments so that
then defaults in the .opt files could be set to that. Sadly,
options in GCC are processed before the values of constants
like PTRDIFF_MAX for the target are known, and deferring
the handling of just the -Wxxx-larger-than= options until
the constants have been computed would be too involved to
make it worth the effort.
To keep things simple I decided to have the code that handles
each of the affected options treat the HOST_WIDE_INT_MAX default
as a special request to substitute the value of PTRDIFF_MAX at
The attached patch implements this.
I wonder if documenting a special value of -1 would be easier for
users to use. Your patch doesn't come with adjustments to
invoke.texi so I wonder how people could know of this special
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.)
I don't consider this the most elegant design but it's the best
I could think of short of complicating things even more.