I have the following snippet of code:
foo();
std::cout << "Foo";
loop();
Where loop
is a function that does not terminate because it runs into some infinite loop (not intentional). However, it seems like my program is running into the infinte loop without printing the output ("Foo"). Is the compiler allowed to change the behavior of the code in this way?
Neither foo()
nor loop()
interfere with standard output.
Unfortunately, I cannot give more specific information about the setup. So I just want do know whether there needs to be a bug (in code or compiler) before the call of loop()
or if the compiler is allowed to assume that later code is bugfree?
Edit: The reason for this behavior is probably a missing std::flush
. The original question is therefore not that interesting for me anymore (but it probably is still a question one can ask).