As I wrote an answer to How is it possible to use pow without including cmath library I fear to have proven that missing an include of a needed header is actually undefined behavior, but since I have not found any consent of that fact I like to impose the formal question:
Is missing a required header i.e.
#include <iostream>
int main()
{
std::cout << std::pow(10, 2);
}
- Ill-formed ( [defns.ill.formed] ) code?
- Invoking undefined behavior ( [defns.undefined] )?
- If it is not 1 and 2, is it unspecified behavior [defns.unspecified] or implementation-defined behavior [defns.impl.defined]?
- If not 1. i.e. if this code is well-formed, wouldn't that contradict [using.headers] and [intro.compliance] "accept and correctly execute a well-formed program"?
As in my answer I tend to affirm both questions, but [using.headers] is very confusing because of Difference between Undefined Behavior and Ill-formed, no diagnostic message required . As [defns.well.formed] implies that a program constructed to the ODR is well formed, and there is specification of whenever the for example iostream
must not define pow
, one could argue this is still unspecified behavior ( [defns.unspecified]). I don't want to rely only of my standard interpretation skills for a definitive answer for such an important question. Note that the accepted i.e. the only other answer does not answer if the code is UB nor does the question asks it.