[RFC] Fix -I ""

Jie Zhang jie@codesourcery.com
Wed Dec 15 15:17:00 GMT 2010


Currently gcc behaves weirdly when an empty string argument passed to -I 
option.

On x86_64-linux-gnu, the latest gcc from trunk:
$ gcc -I "" -c -o t.o t.c
cc1: warning: t.c: not a directory [enabled by default]
[hang]

$ gcc-4.5 -I "" -c -o t.o t.c
[hang]

$ gcc-4.4 -I "" -c -o t.o t.c
cc1: error: t.c: not a directory
[hang]

$ gcc-4.3 -I "" -c -o t.o t.c
cc1: error: t.c: not a directory

For cross compiler from latest trunk:
$ arm-none-linux-gnueabi-gcc -I "" -c t.c -o t.o
cc1: fatal error: 
/scratch/jie/fsf-arm-linux-gnueabi/install/bin/../lib/gcc/arm-none-linux-gnueabi/4.6.0/: 
No such file or directory
compilation terminated.

This issue occurs because do_spec_1 drops the empty string argument.

The attached patch changes do_spec_1 not to drop empty string argument 
and change other places to print "" for such argument when verbose.

Another way to fix this issue might change gcc to error out for -I "". 
But I think accepting it and passing it down is better. If empty string 
argument is an error, subcommands should report it. In this case, the 
compiler don't think it's an error

Bootstrapped on x86_64-linux-gnu and regression tested with c,c++,lto.

Is it OK?


Regards,
-- 
Jie Zhang

-------------- next part --------------
A non-text attachment was scrubbed...
Name: gcc-empty-include-dir.diff
Type: text/x-diff
Size: 2387 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20101215/54057313/attachment.bin>


More information about the Gcc-patches mailing list