[Bug c/59717] New: better warning when using functions when including appropriate header files

metherid at gmail dot com gcc-bugzilla@gcc.gnu.org
Wed Jan 8 07:27:00 GMT 2014


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59717

            Bug ID: 59717
           Summary: better warning when using functions when including
                    appropriate header files
           Product: gcc
           Version: 4.8.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: metherid at gmail dot com

Clang produces a better warning suggesting the appropriate header file compared
to GCC.  Test program included

$gcc testwarning.c 

testwarning.c: In function ‘main’:
testwarning.c:4:2: warning: incompatible implicit declaration of built-in
function ‘strcpy’ [enabled by default]
  strcpy(teststr, "foo");
  ^

rahul@mether ~/work> clang test

testfor  testfor.c  testwarning.c  
rahul@mether ~/work> clang testwarning.c 
testwarning.c:4:2: warning: implicitly declaring library function 'strcpy' with
      type 'char *(char *, const char *)'
        strcpy(teststr, "foo");
        ^
testwarning.c:4:2: note: please include the header <string.h> or explicitly
      provide a declaration for 'strcpy'

---

cat testwarning.c 
int main (void) {

    char *teststr;
    strcpy(teststr, "foo");
---


More information about the Gcc-bugs mailing list