If I have this code:
class A { ... };
class B { ... };
void dummy()
{
A a(...);
B b(...);
...
}
I know that variables a
and b
will be destroyed in reverse allocation order (b
will be destroyed first, then a
); but can I be sure that the optimizer will never swap the allocation and construction of a
and b
? Or I must use volatile
to enforce it?