This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] correct/improve handling of -Walloc-size-larger-than (PR 82063)


On 05/18/2018 05:58 PM, Martin Sebor wrote:
> The -Walloc-size-larger-than= option is supposed make it possible
> to disable the warning by specifying a limit that's larger than
> the default of PTRDIFF_MAX (the handler for the option argument
> gets around the INT_MAX maximum for numeric arguments by accepting
> suffixes like MB or GB).  Unfortunately, a silly typo in the handler
> prevents this from working correctly, and because there is no
> -Wno-alloc-size-larger-than option it's impossible to suppress
> unwanted instances of this warning.
> 
> The attached patch removes these shortcomings by:
> 
> 1) fixing the typo,
> 2) letting the argument handler accept excessively large arguments
>    (> ULLONG_MAX) and treat them as infinite,
> 3) adding -Wno-alloc-size-larger-than option to disable the warning
> 
> The patch also issues a warning for invalid arguments (they either
> reset the limit to zero or leave it at PTRDIFF_MAX otherwise).
> 
> I'm looking for approval to commit this patch to trunk and all
> release branches that support the option (8 and 7).
> 
> For trunk, as the next step, I'd like to generalize the argument
> handler and move it where other similar options (for example,
> -Wlarger-than, -Walloca-larger-than, -Wframe-larger-than, and
> -Wstack-usage) can make use of it.
> 
> Martin
> 
> gcc-82063.diff
> 
> 
> PR c/82063 - issues with arguments enabled by -Wall
> 
> gcc/c-family/ChangeLog:
> 
> 	PR c/82063
> 	* c.opt (-Wno-alloc-size-larger-than): New option.
> 
> gcc/ChangeLog:
> 
> 	PR c/82063
> 	* calls.c (alloc_max_size): Correct a logic error/typo.
> 	Treat excessive arguments as infinite.  Warn for invalid arguments.
> 
> gcc/testsuite/ChangeLog:
> 
> 	PR c/82063
> 	* gcc.dg/Walloc-size-larger-than-1.c: New test.
> 	* gcc.dg/Walloc-size-larger-than-10.c: New test.
> 	* gcc.dg/Walloc-size-larger-than-11.c: New test.
> 	* gcc.dg/Walloc-size-larger-than-12.c: New test.
> 	* gcc.dg/Walloc-size-larger-than-13.c: New test.
> 	* gcc.dg/Walloc-size-larger-than-14.c: New test.
> 	* gcc.dg/Walloc-size-larger-than-15.c: New test.
> 	* gcc.dg/Walloc-size-larger-than-16.c: New test.
> 	* gcc.dg/Walloc-size-larger-than-17.c: New test.
> 	* gcc.dg/Walloc-size-larger-than-2.c: New test.
> 	* gcc.dg/Walloc-size-larger-than-3.c: New test.
> 	* gcc.dg/Walloc-size-larger-than-4.c: New test.
> 	* gcc.dg/Walloc-size-larger-than-5.c: New test.
> 	* gcc.dg/Walloc-size-larger-than-6.c: New test.
> 	* gcc.dg/Walloc-size-larger-than-7.c: New test.
> 	* gcc.dg/Walloc-size-larger-than-8.c: New test.
> 	* gcc.dg/Walloc-size-larger-than-9.c: New test.
> 	* gcc.dg/Walloc-size-larger-than.c: New test.
OK for the trunk.  Not sure this is really a regression, so it'd need
Richi or Jakub to approve for the release branches.

Jeff


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]