...
There are existing compiler implementations that allow const-qualified values objects to be modified without generating a warning message.
Avoid casting away const qualification because doing so makes it easier to modify const-qualified values objects without issuing diagnostics. See EXP05-C. Do not cast away a const qualification for more details.
...
The following well-formed, but noncompliant, code example specified in subclause 6.5.16.1 of the C Standard allows a constant value object to be modified:
| Code Block | ||||
|---|---|---|---|---|
| ||||
const char **cpp;
char *p;
const char c = 'A';
void func(void) {
cpp = &p; /* Constraint violation */
*cpp = &c; /* Valid */
*p = 0; /* Valid */
} |
...