I have the following code snippet that is assigned the type nullptrto bool.
#include <iostream>
int main()
{
bool b = nullptr;
std::cout << b;
}
In clang 3.8.0 it works fine. he gives way out 0. Clang demo
But g ++ 5.4.0 will throw an error:
source_file.cpp: In function ‘int main()’:
source_file.cpp:5:18: error: converting to ‘bool’ from ‘std::nullptr_t’ requires direct-initialization [-fpermissive]
bool b = nullptr;
Which compiler is right?
source
share