Skip to content

Comment on GCC and C vs C++ Speed, Measuredparent

Comments

> So would not both gcc versions be expected to be very similar on instruction level?

It's going to go through the g++ frontend, parsing and compiling it using C++ semantics. There's no guarantee that the C subset of C++ will yield the exact same result as that of an actual C compiler. And a decade or two ago, as TFA notes, it most definitely did not.

I guess I just assumed that considering that both compilers are part of the same compiler collection that their output, while not guaranteed to be the same, can be expected to be somewhat similar. And that the divergences should not have all that much of an impact on execution speed. But I guess I did jump to a conclusion there.

The backend should do the same thing, but if the C++ frontend gives complete garbage to the backend, I guess there's only so much the backend can do to fix the mess.

AboutSource Built by g1lg1l

Hackerly is an independent reader for Hacker News, built on the public HN API. Not affiliated with Y Combinator.