If to abstract from questions of quality of implementation of compilers C vs. With ++, the same code in C and C ++ can differ in speed only if it differs in semantics. That is, it will only be “the same code” in such a situation from a purely cosmetically-visual point of view.
You can roughly go to the differences in the rules of the name lookup
struct S { int a[10]; }; int main() { struct Local { struct S { int a[10000]; } s; }; struct S s = { 0 }; // `sizeof s`??? }
In the C language, a “big” object is declared and reset, and in C ++, a “small” object is declared. But this is too rough.
The property of the C ++ language to carefully preserve the lvalue of the results of expressions will cause the loop
for (unsigned n = sizeof (1 ? "Hello" : "World"); n > 0; --n) ;
different number of times in C and in C ++ will be executed. This is also a rather rude reception.
Further worth mentioning the following
const int N = 10; int A[N][N][N];
In C ++, this is a regular array, and in C, it is a Variable Length Array with potential overhead at runtime.
Continuing the VLA theme, the operand of such a sizeof in C is a computable expression (meaning the above declaration A )
unsigned n = sizeof A[rand() % N][rand() % N];
And although, according to the C language specification, the calculation of index-expressions is not required in this case (because the result does not depend on them), the compiler has the right to calculate them (GCC, which is interesting, calculates). In C ++, the sizeof operand is never computable; such sizeof calculated at compile time and does not generate executable code.
A heap of trifles can be hidden in the differences of the rules sequencing these languages. The same property of preserving the lvalue-ness of the results of expressions in C ++ leads to the fact that its rules are more strict and restrictive sequencing than analogous rules in C. This could theoretically lead to more efficient code in C. it gave a tangible effect offhand is not easy.)
The potential need for exception handling in C ++ and stack promotion is another reason why almost any identical C and C ++ code can be interpreted less efficiently in C ++.