public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/11810] New: gcc -pipe -ox.o -c x.c  writes erroneous x.o on compile error
@ 2003-08-05 18:21 deweese at ict dot usc dot edu
  2003-08-05 18:27 ` [Bug c/11810] " pinskia at physics dot uc dot edu
                   ` (9 more replies)
  0 siblings, 10 replies; 13+ messages in thread
From: deweese at ict dot usc dot edu @ 2003-08-05 18:21 UTC (permalink / raw)
  To: gcc-bugs

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


^ permalink raw reply	[flat|nested] 13+ messages in thread
[parent not found: <bug-11810-6671@http.gcc.gnu.org/bugzilla/>]

end of thread, other threads:[~2010-05-22 17:57 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-08-05 18:21 [Bug c/11810] New: gcc -pipe -ox.o -c x.c writes erroneous x.o on compile error deweese at ict dot usc dot edu
2003-08-05 18:27 ` [Bug c/11810] " pinskia at physics dot uc dot edu
2003-08-05 18:28 ` [Bug debug/11810] " pinskia at physics dot uc dot edu
2003-08-05 18:31 ` [Bug driver/11810] " pinskia at physics dot uc dot edu
2003-08-23  1:09 ` dhazeghi at yahoo dot com
2003-12-16 19:49 ` geoffk at gcc dot gnu dot org
2003-12-16 19:50 ` geoffk at gcc dot gnu dot org
2003-12-16 19:51 ` geoffk at gcc dot gnu dot org
2004-08-12 18:27 ` pinskia at gcc dot gnu dot org
2005-08-07  5:13 ` pinskia at gcc dot gnu dot org
2005-08-07  5:15 ` pinskia at gcc dot gnu dot org
     [not found] <bug-11810-6671@http.gcc.gnu.org/bugzilla/>
2009-11-04 15:47 ` nathan at gcc dot gnu dot org
2010-05-22 17:57 ` jsm28 at gcc dot gnu dot org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).