2 ms·
What is an "escaping aggregate"?; this term has 80 hits on Google, none of which seem to be related to programming. Looking it up “aggregate” is a C++ term for
by Blikkentrekker 5y ago
What is an "escaping aggregate"?; this term has 80 hits on Google, none of which seem to be related to programming.
Looking it up “aggregate” is a C++ term for which the standard indeed does explicitly allow various optimizations and guarantees about data layout are weakened; this is not the case with C arrays.
Do you have any practical evidence to C compilers altering the data layout of an array in any way?
- throwaway17_17 5y agoGP’s comment is referring to Scalar Replacement of Aggregates on the one hand. This is an optimization where by the compiler will, for a function with a Struct argument, only pass in a pointer to / copy of the actual element of the struct used inside a function. Hence the name, the compiler is replacing the aggregate struct by one or more of the individual values it contains. The reference to non-escaping aggregates, describes the compiler optimizing a local only struct by keeping the individual elements in registers during usage, and because the struct as a whole does not leave the local scope, these elements are just discarded when that scope closes. Both of these transformations/optimizations are performed by all three industrial C and C++ compilers (gcc/llvm/msvc).
- gpderetta 5y agoExactly. Thanks.