[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: bug or a feature
From: |
Robert Heller |
Subject: |
Re: bug or a feature |
Date: |
Mon, 04 Jul 2005 21:01:22 +0200 |
Anakreon <anakreonmejdi@yahoo.gr>,
In a message on Mon, 04 Jul 2005 20:42:16 +0300, wrote :
A> Paul Pluzhnikov wrote:
A> > Anakreon <anakreonmejdi@yahoo.gr> writes:
A> >
A> >
A> >>I think the compiler ought to stop the compilation with an error
A> >>since the 2 methods of the bug class are not implemented.
A> >
A> >
A> > You are incorrect: if the compiler stopped compilation, it would
A> > be impossible to compile programs consisting of multiple source
A> > files: e.g. a program in which bug::meth1() is defined in a separate
A> > bug.cc file.
A> >
A> >
A> >>If this is not a feature,
A> >
A> >
A> > It's not a feature and it's not a bug; it's *correct* behaviour.
A> >
A> >
A> >>I'll make a proper bug submission
A> >
A> >
A> > Please don't (waste your and someone else's time).
A> >
A> > Cheers,
A> The command used for the compilation is:
A> g++ -o bug gcc_bug.cpp
A>
A> The compiler must know that there are no other files involved.
No it doesn't. The 'g++' program is just a wrapper. It calls the
preprocessor on gcc_bug.cpp, yielding /tmp/<mumble>.i, then the c++
compiler front end on /tmp/<mumble>.i, yielding /tmp/<mumble>.s, then
the assembler on /tmp/<mumble>.s, yielding /tmp/<mumble>.o, then it runs
the linker on /tmp/<mumble>.o, yielding ./bug. If the command line was:
g++ -o bug gcc_bug.cpp bug_meth1.cpp
The 'compiler' would be run twice, once for each .cpp file (after the
preprocessor was run twice). And the assembler would also be run twice,
yielding *two* .o files (under /tmp). Each run of the compiler is over
a single source file and the compiler does not know if that source is
the only source file or not.
Note your command like could also have been:
g++ -o bug gcc_bug.cpp -lbug
where libbug.a (or libbug.so) was created separately and contains
bug::meth1() and bug::meth2(). The compiler has no way of dealing with
library files -- that is for the linker to process.
A>
A> I don't want to waste anybodys time but shouldn't the compiler
A> report an error on the above case?
Nope. There are no errors! It is NOT an error to declare unused
methods or functions.
A>
A>
A>
A>
\/
Robert Heller ||InterNet: heller@cs.umass.edu
http://vis-www.cs.umass.edu/~heller || heller@deepsoft.com
http://www.deepsoft.com /\FidoNet: 1:321/153