Yes, I think the standard says that this is undefined.
The standard is highly technical though. Google for "C++ standard draft" and see what it has to say about const_cast and cv_qualifiers.
In any case, const_cast was probably not meant for you to modify variables that you have declared const (they may be put into some read-only memory, and therefore the second pointer, if you try to change the value through it, needs to point to some other write-able memory).
A valid use is working around old 3rd-party libraries that haven't been written in a const-correct way. There may be situations where you need to cast away const-ness, but not to change the value, but to be able to use this old code.
Here's a hypothetical example.
/*suppose this is from a third-part library,
that you have paid for and can't change.
Note, that the first argument is non-const,
although the function clearly won't change it.
Function returns pointer to 0-terminator if
character not found.
char* Find(char* p, char ch)
for ( ; *p; p++)
if (*p == ch)
/*suppose we wnat to write a better find function,
that can start search at a chosen position in the string.
Now we don't want to rewrite everything, but use the
existing library as much as possible.
But we certainly want to write const-correct code.
The function doesn't change the string, hence it is
char* better_find(const char* p, char ch, unsigned from)
can't call Find without const_cast, because p is
constant, and can only be passed to functions that
guarantee not to change it (const argument).
It's OK though, because we know for sure, that Find
will not try to modify it.
return Find(const_cast<char*>(p) + from, ch);
char s = "Don't cast away constness unless you need to.";
std::cout << s << '\n';
std::cout << Find(s, 'c') << '\n';
std::cout << better_find(s, 'c', 10);