Open jsonn opened 6 years ago
This bug is still present in the latest llvm/clang builds/code.
The constructs like
(void) stpncpy;
trigger incorrect clang warning error: call to undeclared library function 'stpncpy' with type 'char *(char *, const char *, unsigned long)'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
, while there is no implicit function declaration in the code.
This happens only when the compiler has built-in replacement for used functions.
The same for the constructs like
(void) &stpncpy;
See also:
You can add -fno-builtin
to disable this behavior
You can add
-fno-builtin
to disable this behavior
Yes, thanks. This workaround is used by autoconf
.
However, the warning itself is still incorrect and should be fixed.
Extended Description
A common way to do autoconf-style tests for declarations in headers uses the following approach:
int main(void) { (void)strlcpy; return 0; }
This should fail with unknown identifier errors, but currently passes with a implicit prototype warning for GNUish language modes (i.e. gnu89, gnu99 etc). It fails for "unknown" identifiers like strlcpy2. This is a pretty bad error as it can lead to incorrect autodetection of system headers.