User account creation filtered due to spam.

Bug 40548 - If a dir on PATH contains a directory named "gcc", badness ensues
Summary: If a dir on PATH contains a directory named "gcc", badness ensues
Status: RESOLVED DUPLICATE of bug 38966
Alias: None
Product: gcc
Classification: Unclassified
Component: c (show other bugs)
Version: 4.3.2
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-06-25 00:10 UTC by Paul Smith
Modified: 2009-06-25 05:00 UTC (History)
5 users (show)

See Also:
Host: x86_64-unknown-linux-gnu
Target: x86_64-unknown-linux-gnu
Build: x86_64-unknown-linux-gnu
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Paul Smith 2009-06-25 00:10:37 UTC
I have a directory on my PATH that contains a subdirectory named "gcc".  When I run "gcc" (not fully-qualified) I get all sorts of very bizarre behavior.  For example:

$ cat t.c
#include <limits.h>

$ mkdir gcc

$ PATH=.:$PATH gcc -E t.c >/dev/null
In file included from /tmp/t.c:1:
/usr/include/limits.h:125:26: error: no include path in which to search for limits.h

But, if I don't have a local directory "gcc" then all is fine:

$ rmdir gcc
$ PATH=.:$PATH gcc -E t.c >/dev/null
$

If I use a fully-qualified path for GCC (/usr/bin/gcc) then it also does not fail.

It looks to me like the test GCC performs when looking for itself through PATH just checks for executability (if I have a non-executable file in a directory on PATH this doesn't happen) but doesn't check for directory-ness.  This is wrong, because the shell's PATH search algorithm DOES check for directory-ness and skips directories that appear in directories on your PATH.
Comment 1 Andrew Pinski 2009-06-25 01:25:03 UTC

*** This bug has been marked as a duplicate of 38966 ***
Comment 2 Paul Smith 2009-06-25 05:00:02 UTC
Ah, thanks for the pointer.  I did search before I created a new bug but wasn't successful in narrowing down my search to something reasonable.  It would be nice if the "real" bug mentioned PATH in the summary; I was trying to use case-sensitive searches for PATH but searching comments turned up >150 bugs.