[Bug c/37995] New: using <stdio.h> fails if gcc invoked in a directory which has a subdirectory called "gcc"

mvanier at cs dot caltech dot edu gcc-bugzilla@gcc.gnu.org
Sun Nov 2 08:49:00 GMT 2008


I tried to compile the following trivial program, called 'hello.c':

#include <stdio.h>

int main(void)
{
    printf("hello, world!\n");
    return 0;
}

using gcc, in a directory which had a subdirectory called "gcc".  This caused
the compile to fail with the following output:

> gcc hello.c 
In file included from hello.c:1:
/usr/include/stdio.h:34:21: error: stddef.h: No such file or directory
In file included from /usr/include/stdio.h:75,
                 from hello.c:1:
/usr/include/libio.h:53:21: error: stdarg.h: No such file or directory
In file included from /usr/include/stdio.h:75,
                 from hello.c:1:
/usr/include/libio.h:332: error: expected specifier-qualifier-list before
‘size_t’
/usr/include/libio.h:364: error: expected declaration specifiers or ‘...’
before ‘size_t’
/usr/include/libio.h:373: error: expected declaration specifiers or ‘...’
before ‘size_t’
/usr/include/libio.h:489: error: expected declaration specifiers or ‘...’
before ‘__gnuc_va_list’
/usr/include/libio.h:491: error: expected declaration specifiers or ‘...’
before ‘__gnuc_va_list’
/usr/include/libio.h:493: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or
‘__attribute__’ before ‘_IO_sgetn’
In file included from hello.c:1:
/usr/include/stdio.h:312: error: expected declaration specifiers or ‘...’
before ‘size_t’
/usr/include/stdio.h:319: error: expected declaration specifiers or ‘...’
before ‘size_t’
/usr/include/stdio.h:347: error: expected declaration specifiers or ‘...’
before ‘__gnuc_va_list’
/usr/include/stdio.h:352: error: expected declaration specifiers or ‘...’
before ‘__gnuc_va_list’
/usr/include/stdio.h:355: error: expected declaration specifiers or ‘...’
before ‘__gnuc_va_list’
/usr/include/stdio.h:361: error: expected declaration specifiers or ‘...’
before ‘size_t’
/usr/include/stdio.h:363: error: format string argument not a string type
/usr/include/stdio.h:365: error: expected declaration specifiers or ‘...’
before ‘size_t’
/usr/include/stdio.h:366: error: expected declaration specifiers or ‘...’
before ‘__gnuc_va_list’
/usr/include/stdio.h:367: error: format string argument not a string type
/usr/include/stdio.h:678: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or
‘__attribute__’ before ‘fread’
/usr/include/stdio.h:684: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or
‘__attribute__’ before ‘fwrite’
/usr/include/stdio.h:706: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or
‘__attribute__’ before ‘fread_unlocked’
/usr/include/stdio.h:708: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or
‘__attribute__’ before ‘fwrite_unlocked’

The compile works fine if there is no subdirectory called "gcc".  Although this
seems trivial, some programs' source code do indeed have subdirectories called
"gcc" and this causes them to fail to compile.  I don't know if this is
intended behavior or not, but I can't find any information about it in the gcc
documentation.  This compile was on an up-to-date Arch Linux system with gcc
4.2.3 which I compiled myself from source.  I have tried it on a Mac Pro using
gcc 4.0.1 and the problem does not manifest in that version.  gcc 4.2.3 was
built with standard compilation options; the only non-standard configure option
was --enable-languages=c,c++,objc and there were no options used for make or
make install.

If the -save-temps option is passed to gcc:

> gcc -save-temps hello.c

the result is:

> gcc -save-temps hello.c
In file included from hello.c:1:
/usr/include/stdio.h:34:21: error: stddef.h: No such file or directory
In file included from /usr/include/stdio.h:75,
                 from hello.c:1:
/usr/include/libio.h:53:21: error: stdarg.h: No such file or directory

and when gcc is run on hello.i, the errors output are the same as those above.

Interestingly, when I manually invoke cpp to generate hello.i:

> cpp hello.c > hello.i
> gcc hello.i

there are no errors and the a.out file generated works as intended.  This is
with cpp version 4.2.3, created in the same compile as that which created gcc. 
However, substituting gcc -E for cpp doesn't work:

> gcc -E hello.c > hello.i

In file included from hello.c:1:
/usr/include/stdio.h:34:21: error: stddef.h: No such file or directory
In file included from /usr/include/stdio.h:75,
                 from hello.c:1:
/usr/include/libio.h:53:21: error: stdarg.h: No such file or directory


-- 
           Summary: using <stdio.h> fails if gcc invoked in a directory
                    which has a subdirectory called "gcc"
           Product: gcc
           Version: 4.3.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: mvanier at cs dot caltech dot edu
 GCC build triplet: i686-pc-linux-gnu
  GCC host triplet: i686-pc-linux-gnu
GCC target triplet: i686-pc-linux-gnu


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



More information about the Gcc-bugs mailing list