This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/11810] New: gcc -pipe -ox.o -c x.c writes erroneous x.o on compile error
- From: "deweese at ict dot usc dot edu" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 5 Aug 2003 18:21:46 -0000
- Subject: [Bug c/11810] New: gcc -pipe -ox.o -c x.c writes erroneous x.o on compile error
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=11810
Summary: gcc -pipe -ox.o -c x.c writes erroneous x.o on compile
error
Product: gcc
Version: 3.3.1
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: c
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: deweese at ict dot usc dot edu
CC: gcc-bugs at gcc dot gnu dot org
GCC build triplet: i386-pc-linux-gnu
GCC host triplet: i386-pc-linux-gnu
GCC target triplet: i386-pc-linux-gnu
GCC incorrectly generates an output .o file even if there is a compiler
error under the following conditions:
-pipe is enabled, -c is enabled, and -o<objname>.o is specified.
The output object file is slightly different than an object file generated
from a C file without a minor compiler error, for example if the word ERROR
is added arbitrarily to the C file. Under these error conditions,
some symbols go missing from the output object file.
I have verified that the error occurs on gcc 2.95, 3.0.4, 3.2.3, and 3.3.1.
>How-To-Repeat:
Create a file "foo.c" with the following content, sans angle brackets:
>>>>
#include <stdio.h>
int main(int argc, char** argv) {
ERROR
printf("Hello World.\n");
return 0;
}
<<<<
Execute the following command with any version of gcc:
gcc -pipe -ofoo.o -c foo.c
The output is as follows:
foo.c: In function main':
foo.c:4: error: ERROR' undeclared (first use in this function)
foo.c:4: error: (Each undeclared identifier is reported only once
foo.c:4: error: for each function it appears in.)
foo.c:4: error: syntax error before "printf"
However, foo.o is written out. Subsequently, linking it causes an error:
gcc test.o
The output is:
/usr/lib/gcc-lib/i386-linux/3.3.1/../../../crt1.o(.text+0x18): In function
_start':
: undefined reference to main'
collect2: ld returned 1 exit status