Does copying exist in C?

When I read about copying, many of the sources only mention C ++ and not C.

They indicate how the C ++ standard permits this optimization if the compiler decides it is the right thing to do.

But what about C? Do C compilers make copying, or is it standard C gaurentee that copies will never be optimized?

+3


source to share


1 answer


Both C and C ++ allow any optimizations that follow the as-if rule. Because C has no constructors, and therefore side-effect copy constructors can be excluded without breaking this rule. C ++, on the other hand, has to make a special case where implementations are allowed to interrupt as-if.



So, a copy of elision exists in C implicitly through an as-if rule.

+5


source







All Articles