If a file has errors and gcc gets the -V X.X.X command line option, then the
exit code is 0. The following illustrates it:

[zoltan manocska]~>arm-elf-gcc --version
arm-elf-gcc (GCC) 4.4.0
Copyright (C) 2009 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

[zoltan manocska]~>echo "@" > test.c 
[zoltan manocska]~>arm-elf-gcc -c test.c
test.c:1: error: stray �...@’ in program
[zoltan manocska]~>echo $?
1
[zoltan manocska]~>arm-elf-gcc -V 4.4.0 -c test.c
test.c:1: error: stray �...@’ in program
[zoltan manocska]~>echo $?                       
0
[zoltan manocska]~>arm-elf-gcc -V 4.0.2 -c test.c
test.c:1: error: stray �...@’ in program
[zoltan manocska]~>echo $?                       
0

In a makefile, where a specific compiler is chosen, this bug causes very severe
headaches. I don't know if it's true for all targets, but I tried it with
arm-elf and mips-elf, they both show the same erroneous behaviour. Before the
4.4.0 compiler was installed, the 4.0.2 compiler did not exhibit this bug:

[zoltan manocska]~>arm-elf-gcc-4.0.2 -c test.c 
test.c:1: error: stray �...@’ in program
[zoltan manocska]~>echo $?                     
1
[zoltan manocska]~>arm-elf-gcc-4.0.2 -V 4.0.2 -c test.c
test.c:1: error: stray �...@’ in program
[zoltan manocska]~>echo $?                             
1
[zoltan manocska]~>arm-elf-gcc-4.0.2 -V 4.4.0 -c test.c
test.c:1: error: stray �...@’ in program
[zoltan manocska]~>echo $?                             
1


-- 
           Summary: Using the -V option makes the compiler to exit with 0
                    exit code on error
           Product: gcc
           Version: 4.4.0
            Status: UNCONFIRMED
          Severity: major
          Priority: P3
         Component: c
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: zoltan at bendor dot com dot au
  GCC host triplet: x86-elf-linux
GCC target triplet: arm-elf-none


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

Reply via email to