Skip to content

Instantly share code, notes, and snippets.

@eiennohito
Created February 7, 2012 13:37
Show Gist options
  • Save eiennohito/1759702 to your computer and use it in GitHub Desktop.
Save eiennohito/1759702 to your computer and use it in GitHub Desktop.
C++11 nullptr constexpr problem (Example from Chandler Carruth's speech on GoingNative 2012)
#include <iostream>
struct S { int n; };
struct X { X(int) {} };
void f(void*) {
std::cerr << "Pointer!\n";
}
void f(X) {
std::cerr << "X!\n";
}
int main() {
f(S().n);
}
@eiennohito
Copy link
Author

eien@eien-ubuntu:/dev/dev$ clang++ -std=c++11 problem.cpp
eien@eien-ubuntu:
/dev/dev$ ./a.out
Pointer!
eien@eien-ubuntu:/dev/dev$ clang++ -std=c++03 problem.cpp -o a03
eien@eien-ubuntu:
/dev/dev$ ./a03
X!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment