On 1/28/19 9:43 AM, Joseph Myers wrote:
On Mon, 28 Jan 2019, Martin Sebor wrote:

On 1/25/19 6:25 PM, Joseph Myers wrote:
It's also broken the build of the glibc testsuite, e.g.:

../time/time.h:88:15: error: mismatch in argument 1 type of built-in
function 'strftime'; expected 'char *'
[-Werror=builtin-declaration-mismatch]
     88 | extern size_t strftime (char *__restrict __s, size_t __maxsize,

(presence or absence of qualifiers on a parameter is not part of the
function type and should not be compared here).

Not sure I see which pointer the warning is complaining about but
detecting mismatches in constness is intentional.  Users will want
to know when they accidentally swapped the arguments of, say,
memcpy, and declared it as:

It's about qualifiers on the pointer itself (which do not affect the
function's type, although such qualifiers in the function definition
affect code inside the function), not qualifiers on the pointer target
type.  GCC can't assume whether system headers do or do not have the
"restrict" qualification on some parameters that's included in C99
(essentially as documentation of aliasing requirements for parameters for
those functions), nor do GCC's built-in function declarations have that
"restrict" anywhere.  But it's complaining here about a mismatch between
"char *restrict" and "char *".

I see.  That's certainly not intentional.  Looks like we need better
tests.  None of the ones I added focus on exercising qualifiers, and
I can't find any others for the warning that do either.

Martin

Reply via email to