FS#11971 - gcc can't compile "hello, world!" in a directory with a subdirectory called "gcc"

Attached to Project: Arch Linux
Opened by Michael Vanier (mvanier) - Monday, 03 November 2008, 08:43 GMT
Last edited by Andreas Radke (AndyRTR) - Thursday, 06 November 2008, 20:17 GMT
Task Type Bug Report
Category Packages: Extra
Status Closed
Assigned To Jan de Groot (JGC)
Andreas Radke (AndyRTR)
Architecture All
Severity Low
Priority Normal
Reported Version None
Due in Version Undecided
Due Date Undecided
Percent Complete 100%
Votes 0
Private No

Details

Description:

I found a bug which makes the Arch ABS package for drscheme fail to compile; however, this bug has nothing to do with drscheme itself. Drscheme happens to have a subdirectory called "gcc", and apparently, this makes the Arch version of gcc very unhappy. Here is a very simple example. Take this file, called "hello.c":

#include <stdio.h>

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

Then make a subdirectory in the same directory where "hello.c" lives, and call it "gcc":

% mkdir gcc

Then try to compile "hello.c":

% gcc hello.c

You get this 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’

What's worse is that the compile goes smoothly if you give an explicit path for gcc:

% /usr/bin/gcc hello.c
% a.out
hello, world!

However, the gcc in the path is definitely /usr/bin/gcc:

% which gcc
/usr/bin/gcc

This is driving me crazy, so I hope you can figure out what's going on.

Additional info:
* package version(s)
gcc 4.3.2
* config and/or log files etc.


Steps to reproduce:

See above.
This task depends upon

Closed by  Andreas Radke (AndyRTR)
Thursday, 06 November 2008, 20:17 GMT
Reason for closing:  Not a bug
Comment by Allan McRae (Allan) - Monday, 03 November 2008, 08:53 GMT
I can replicate this by using "export PATH=.:$PATH".
Comment by Andreas Radke (AndyRTR) - Tuesday, 04 November 2008, 13:00 GMT
Putting "." into $PATH doesn't make sense. I don't think it's a bug. Maybe a strange but probably even wanted behavior behavior how bash(?) treats ./gcc preferred over the search in $PATH.
Comment by Jan de Groot (JGC) - Tuesday, 04 November 2008, 14:51 GMT
Having . in $PATH is dangerous and should never be done:
http://www.linux.org/docs/ldp/howto/Path-5.html

Loading...