This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: C++ vs. C asm/object file size



>     FWIW - anyone following the linux kernel list might notice that I'm
> pushing to get the kernel into a state where it is buildable by C++ - NOT
> rewrite it in C++. My hope is that we'd immediately gain the benefit of
> its strong type checking without paying any performance or size penalty.
> This would also allow the inclusion of C++ features in the future as the
> need arises and the compiler generates more efficient code. My purpose of
> this exercise is to confirm (as claimed) or disprove the notion that a C++
> compiler (specifically egcs) will generate bigger, slower programs from
> the exact same source code.

Theoretically you will get the same object code from the same source code
(if your input language is in the common C/C++ subset), because C++ and C
are both converting to the same intermediate form and using the same
backend (provided that you disable exceptions).

In practice, you may find some differences.  If you do, it would be useful
to figure out why, so that we can get better code.  I recall that in the
past, there were some optimizations that didn't occur in the C++ front end
but did in the C front end, but this was unintentional and could be fixed.

> As some of you may recall, an effort was made
> a long while back to build the linux kernel with a previous version of g++
> which suffered from an immature compiler, language standard, and, frankly,
> developers who were inexperienced using C++ is performance-intensive
> applications. I think that the state of g++ has been dramatically improved
> by the egcs team and that the release of kernel 2.2 would be a better base
> to add this as a 2.3 feature.

Regardless of what the Linux kernel team decides to do, it would be useful
feedback for the C++ developers and you might find a few bugs on the way.




Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]