[PATCH] Do not warn with warn_unused_result for alloca(0).

Martin Sebor msebor@gmail.com
Wed Jun 12 17:26:00 GMT 2019

On 6/12/19 10:40 AM, Jakub Jelinek wrote:
> On Wed, Jun 12, 2019 at 10:13:57AM -0600, Martin Sebor wrote:
>> But GCC doesn't support such an implementation, does it?
> Why would that be relevant?

Obviously because it makes no sense to cater to all conceivable
extensions provided by all sorts of implementations out there.

There are libc implementations out there that accept null pointer
arguments to functions like memcpy with zero sizes, for example.
Or those that accept overlapping objects in calls to strcpy.  GCC
itself handles those gracefully, yet warns for such constructs
nonetheless.  It's useful because those misuses are likely hidden
bugs, even if they don't always manifest themselves.

> The warning would cause people to make portable
> code less portable (by removing the alloca (0) calls that were added there
> for portability reasons), or add hacks to work around the warning (whether
> #pragma GCC diagnostic or something else).  That is something we do not
> want people to do.

You asked for input and I gave it to you.  If your mind was already
made up and you're only willing to accept feedback that agrees with
your view, don't ask.


More information about the Gcc-patches mailing list