Well, why not look bad?
It is poorly formed because it violates the obvious rules for constant correlation. In C ++, you are not allowed to implicitly convert a constant access pass to an non-constant access path. The same goes for pointers and references. In order for the whole goal to have permanent access paths: to prevent the modification of the object to which the path leads. Once you have made it permanent, you are not allowed to return to inconstancy unless you make a specific explicit and conscious effort to do this using const_cast .
In this particular case, you can easily remove the constant from the access path using const_cast ( const_cast used for this) and legally change the reference object, since the reference object is not really constant
int main(){ int x = 10; const int &z = x; int &y = const_cast<int &>(z); y = 42;
source share