I believe it is well defined, since the standard only attributes undefined behavior to modify the const object. C ++ 11:
[expr.const.cast] 5.2.11 ยง7
[Note: depending on the type of object, a write operation through a pointer, lvalue, or a pointer to a data element obtained as a result of a const_cast , which discards the qualifier qualifier, can cause undefined behavior (7.1.6.1). -end note]
[dcl.type.cv] 7.1.6.1 ยง4
Except that any member of the class declared mutable (7.1.1) can be modified, any attempt to change a const object during its lifetime (3.8) leads to undefined behavior ....
GetA() does not actually modify any object, so it does not have undefined behavior.
Angew
source share