[Bug tree-optimization/83657] detect invalid calls to built-ins declared without prototype

msebor at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Tue Oct 15 22:30:00 GMT 2019


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

Martin Sebor <msebor at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
      Known to work|                            |9.1.0
         Resolution|---                         |FIXED
   Target Milestone|---                         |9.4
      Known to fail|                            |7.3.0, 8.3.0

--- Comment #2 from Martin Sebor <msebor at gcc dot gnu.org> ---
This has been implemented since GCC 9.

$ cat pr83657.c && gcc -S -Wall pr83657.c
#if __cplusplus
extern "C" void* memcpy (...);
#else
void* memcpy ();
#endif

void f (char *d)
{
  memcpy (3, d, "123");   // invalid, should be diagnosed
}
pr83657.c: In function ‘f’:
pr83657.c:9:11: warning: passing argument 1 of ‘memcpy’ makes pointer from
integer without a cast [-Wint-conversion]
    9 |   memcpy (3, d, "123");   // invalid, should be diagnosed
      |           ^
      |           |
      |           int
pr83657.c:4:7: note: expected ‘void *’ but argument is of type ‘int’
    4 | void* memcpy ();
      |       ^~~~~~
pr83657.c:9:17: warning: passing argument 3 of ‘memcpy’ makes integer from
pointer without a cast [-Wint-conversion]
    9 |   memcpy (3, d, "123");   // invalid, should be diagnosed
      |                 ^~~~~
      |                 |
      |                 char *
pr83657.c:4:7: note: expected ‘long unsigned int’ but argument is of type ‘char
*’
    4 | void* memcpy ();
      |       ^~~~~~


More information about the Gcc-bugs mailing list