3 ms·
> I don't think that C disallows RVO, optimizations should never change the output of a program unless explicitely allowed (the as-if rule). In c++ since RVO
by jcelerier 6y ago
> I don't think that C disallows RVO,
optimizations should never change the output of a program unless explicitely allowed (the as-if rule).
In c++ since RVO is allowed, it is ok for
intptr_t value = 0;
struct foo f() {
struct foo the_foo;
value = (intptr_t)&the_foo;
return the_foo;
}
int main()
{
struct foo the_foo = f();
assert(value == (intptr_t)&the_foo);
}
to assert or not depending on the -O level. But I'd wager that it is not the case in C.