[Bug tree-optimization/80794] constant objects can be assumed to be immutable

msebor at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Wed May 17 17:13:00 GMT 2017


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

--- Comment #6 from Martin Sebor <msebor at gcc dot gnu.org> ---
(In reply to Martin Sebor from comment #5)
> S::i cannot change during the lifetime of an S object because S::i is
> declared const.  This holds regardless of whether the S object itself is
> const.

To be clear, the only way to change S::i is to destroy S or S::i and create a
new object in its storage.  That can be relied on not to happen in s.foo()
because the reference s is seen used after the function returns.


More information about the Gcc-bugs mailing list