Extended Description
Consider the following example:
struct test {
test(test&&);
void Extend(test v);
int data_[4096];
};
test test_func(test t) {
t.Extend(static_cast<test&&>(t));
t.Extend(static_cast<test&&>(t));
return t;
}
With -std=c++11 -O2 flags Clang uses 32768 bytes of stack, GCC uses 16392 bytes.
Note that adding additional t.Extend(static_cast<test&&>(t)); results in stack usage growth for Clang, while GCC keeps using only 16392 bytes.
Godbolt playground: https://godbolt.org/z/MdaNfa
Extended Description
Consider the following example:
With
-std=c++11 -O2flags Clang uses 32768 bytes of stack, GCC uses 16392 bytes.Note that adding additional
t.Extend(static_cast<test&&>(t));results in stack usage growth for Clang, while GCC keeps using only 16392 bytes.Godbolt playground: https://godbolt.org/z/MdaNfa