https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96996

--- Comment #2 from Matthijs Kooijman <matthijs at stdin dot nl> ---
> Replacing non_constant_test with a new object is possible, and allowed. But 
> the name "non_constant_test" cannot be used to refer to the new object, so 
> any calls to non_constant_ref() after the object was replaced would have 
> undefined behaviour. Which means the compiler can assume there are no such 
> calls.

Thanks for clarifying. But then I could reason that *if* "non_constant_test" is
replaced, then accessing it through the old name is undefined behavior, so that
would make any value for the constant member variables (such as the original
values before replacement) acceptable, right? Hence that does not conflict with
applying this optimzation, I'd think.

Reply via email to