https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83657
Bug ID: 83657 Summary: detect invalid calls to built-ins declared without prototype Product: gcc Version: 8.0 Status: UNCONFIRMED Severity: enhancement Priority: P3 Component: tree-optimization Assignee: unassigned at gcc dot gnu.org Reporter: msebor at gcc dot gnu.org Target Milestone: --- As pointed out in bug 83656, GCC (in C mode) fails to issue -Wbuiltin-declaration-mismatch for the not-entirely-compatible memcpy declaration with no prototype in the test case below. This makes it possible to not just overlook such declarations in source code but also miss invalid calls to them as in the following test case. Independent of the fix for bug 83656, this is a request to also detect and diagnose such invalid calls, similarly to how Clang diagnoses them. $ cat d.c && gcc -O2 -S -Wall -Wextra -Wpedantic d.c #if __cplusplus extern "C" void* memcpy (...); #else void* memcpy (); #endif void f (char *d) { memcpy (3, d, "123"); // invalid, should be diagnosed } For reference, Clang issues the following warnings: d.c:5:11: warning: incompatible integer to pointer conversion passing 'int' to parameter of type 'void *' [-Wint-conversion] memcpy (3, d, "123"); ^ d.c:5:17: warning: incompatible pointer to integer conversion passing 'char [4]' to parameter of type 'unsigned long' [-Wint-conversion] memcpy (3, d, "123"); ^~~~~ 2 warnings generated.