Modifying an object declared with const qualifier causes undefined behavior .
In accordance with the standard (primary focus):
C11 6.7.3 / 6 Type Classifiers
If an attempt is made to modify an object defined using a const-qualified type using an lvalue value with a non-constant-qualifying type , the behavior is undefined.
source share