In class static const ODR
I am a bit confused by the static in-class initialization of a const member. For example, in the code below: #include <iostream> struct Foo { const static int n = 42; }; // const int Foo::n; // No ODR void f(const int& param) { std::cout << param << std::endl; } int g(const int& param) { return param; } template<int N> void h() { std::cout << N << std::endl; } int main() { // f(Foo::n); // linker error, both g++/clang++ std::cout << g(Foo::n) << std::endl; // OK in g++ only with -O(1,2 or 3) flag, why?! h<Foo::n>(); // this should be fine } Live example I do not define Foo::n (the line is