This is the mail archive of the
mailing list for the GCC project.
Re: Converting GCC to compilation with C++
> > I'm amazed at seeing how people prefer brittle hacks to working
> > codes. Virtual functions are guranteed to be set properly,
> > once for while. Currently, we do not have such invariants and
> > we have to do everything hands with more opportunities to make
> > mistakes.
On Tue, Jul 13, 2004 at 05:25:44PM -0400, Robert Dewar wrote:
> Well it is interesting to note that the use of dynamic dispatching
> in safety-critical programs is extremetly problematic, and it is
> not at all clear that FAA certification could be achieved for
> programs using such techniques.
Completely irrelevant even if true. GCC is not a safety-critical avionics
system. In any case, virtual functions are generally a lot more reliable
than the equivalent C code that they replace, as they encapsulate a type
test, a switch based on type, possibly a pointer typecast (for example,
from a pointer to a generic node to a pointer to a specific kind of node),
and a call to the correct function to handle that type, in a manner that
forces consistency. Without such features we wind up with the sea of
nested conditionals that litter GCC today.
Virtual functions are a highly constrained form of dynamic dispatch, and
because of the constraints it is still possible to prove safety properties
in some cases. The proper use of private member functions to enforce
invariants can make those proofs a lot easier.
I think I'll let it go at that, as there's not much use in starting a
language war just yet. That can wait until Tom Tromey asks us to accept
his C++ rewrite of the Java front end, gcjx.
Tom writes in his blog: "Working with C++ continues to be interesting. It
is nicely expressive, gcjx is about half the raw line count of the current
gcj. That isn't a completely fair comparison though."