It's not UB in and of itself. You get undefined behavior when you cast away constness and use the obtained glvalue to modify an object which is originally declared const. Here's the standard quote on this ([dcl.type.cv]/4):
Except that any class member declared mutable can be modified, any
attempt to modify a const object during its lifetime results in
undefined behavior.
Merely calling a member function is not a modification of an object. It all depends on what the function does. So if it does something crazy like:
std::memset(this, 0, sizeof(*this));
That would result in undefined behavior, for sure. But assuming it doesn't, and since there are no members for it to modify in an ill-formed manner, there is no UB from the call.
The other question, of whether or not it's a good idea, has an obvious answer. Const casts should not litter code bases. But if the base class is well-behaved, albeit not well-defined, it may be acceptable if you can't change the class.
EmptyBase::bar();
invoid foo() const
? – Jacquiline::bar
would in effect be a static memberfunction? – Batson[basic.type.qualifier]
? Also was that directed to me? – Phillis