LWN.net Logo

Converting GCC to C++

Converting GCC to C++

Posted Jun 18, 2008 19:10 UTC (Wed) by ncm (subscriber, #165)
In reply to: Converting GCC to C++ by pynm0001
Parent article: Converting GCC to C++

The conversion of Gcc will be fundamentally different from gld -> gold.  He will start by just
compiling Gcc with g++.  Then he will re-write parts that have been problems in C to use
safer, more powerful C++ constructs.


(Log in to post comments)

Converting GCC to C++

Posted Jun 18, 2008 19:46 UTC (Wed) by pynm0001 (guest, #18379) [Link]

Sounds good then. I just got through reading the slides and I think there could be great gain by doing nothing more than converting the already-existing object-oriented code (like TARGETS) to appropriate C++ and using the standard C++ containers instead of the various ad-hoc routines that look to be scattered in the code.

Converting GCC to C++

Posted Jun 18, 2008 20:55 UTC (Wed) by jordanb (subscriber, #45668) [Link]

It seems to me that trying to do it piecemeal line-by-line is a good way to end up with "C
code implemented in C++" which is pretty good way to get the worst of both worlds. Anyway his
idea seems to be driving at using RAII for the objects so that he can then start using
exceptions. But wouldn't he have to get destructors for *everything* before he uses any
exception? Otherwise he'll have old C stuff leaking all over the place whenever exceptions
cause it to skip the free call.

So there'd be a huge front-end cost to this no matter what. And given that it seems like the
argument for using C++ (that it's compatible with C) ends up being quite a bit weaker. GCC's
already got a ton of Ada code in the GNAT front end, perhaps he should look at remaking the
backends in Ada and making the front ends all self-hosting. Having to rewrite each component
would at least discourage the appeal of mushing the new C++ code into the old C design.

Converting GCC to C++

Posted Jun 18, 2008 21:16 UTC (Wed) by ncm (subscriber, #165) [Link]

It's easy to speculate, but since he's actually doing the work, we'll see.  If it's not really
better, it won't be merged.

Converting GCC to C++

Posted Jun 19, 2008 12:03 UTC (Thu) by nix (subscriber, #2304) [Link]

'Start using exceptions' is probably quite a bit less important than 'start using typechecked
STL structures in place of rather horrible macros without type-checking'.

Copyright © 2012, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds