What if
B::fwould not have been marked virtual? Is the program ill-formed, then?
Yes, it is. Because in order to override something, that something has to be virtual. Otherwise it’s not overriding, it’s hiding. So, the positive answer follows from the quote in your question.