4 ms·
The cast itself is not undefined. It's completely valid to use a non-const pointer to a const variable for reading that variable (this is actually quite common
by ynik 10y ago
The cast itself is not undefined.
It's completely valid to use a non-const pointer to a const variable for reading that variable (this is actually quite common when interacting with libraries that are not const-correct). Undefined behavior only occurs when the const variable is being modified.