https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108154

Roman Žilka <roman.zilka at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|INVALID                     |---
             Status|RESOLVED                    |UNCONFIRMED

--- Comment #4 from Roman Žilka <roman.zilka at gmail dot com> ---
So be it, as for the application of Wstring-overread. But gcc doesn't use the
integer following "static" as a definite indication of the size upper bound for
any other purpose (code optimization, ...), does it? C (C99, anyway) merely
states that the size of the array shall be at least 'n'. I'm asking because the
part of the quoted error message, which talks about the size of 's', suggests
that gcc may internally consider 's' to be 1 or fewer chars large. Considering
a size >n impossible may, in theory, lead to incorrect unreachability
assertions. Considering a size <n possible may limit optimization (like bug
102556).

By the way, C9X Rationale WG14/N897, 6.7.5.2, gives optimization as the
motivation for the [static n] construct. Of course, security over optimization.

Let me correct myself for the record: f(size_t n, char buffer[static n]) is
equivalent to just "char *buffer", if I'm reading it right. That was not a
valid use case.

Reply via email to