I think it is only modifying that non-const value that is undefined. If you use a nominally mutable value in a read-only way, then you are OK.
This is important because older libs that ignore (or abuse) const will often do read-only access to a char* or something. A nice example is that POSIX defines
int execv(const char *path, char *const argv[]);
That definition takes a constant pointer to variable chars! Worse, some people use the same signature for `main()` and also for libraries that parse `argv`. But none of them are actually allowed to vary those chars under Unix.
This is important because older libs that ignore (or abuse) const will often do read-only access to a char* or something. A nice example is that POSIX defines
That definition takes a constant pointer to variable chars! Worse, some people use the same signature for `main()` and also for libraries that parse `argv`. But none of them are actually allowed to vary those chars under Unix.