Consider the following MCVE:
#include <iostream> int main() { void foo(int); std::cout << foo << std::endl; return 0; }
Here, I intentionally try to print the function pointer incorrectly, so the <<overload operator, which accepts bool .
basic_ostream& operator<<( bool value );
What puzzles me is that gcc 7.2 and clang 5.0 give a warning, but compiles and links the program.
At the same time, Visual Studio 15.5.6 does not bind this example.
Personally, I expected this code to not bind at all, even though the compiler used as foo seems to be using ODR.
Can someone explain why gcc and clang can link the program?
source share