I think it's best to explain my question on a sample code.
Let's say we have got a class:
class Test{
public:
void doThings(){
std::cout << "Hello" << std::endl;
} // theoritically could be static method, but let's make it non static
private:
// members not used by doThings method
};
So We have got class Test and method doThings, that we could as well declare static, be let's say we forgot to do this.
Now my question is: Is a code below undefined behavior?
void func(){
Test* ptr = nullptr;
ptr->doThings();
}
In my opinion it at least should be, but I do not know what does C++ standard state. On the other hand, compiler should generate completely valid code.