Consider this code snippet:
struct Foo {
};
template<typename T>
struct Bar {
const T foo;
};
int main() {
Bar<Foo> test;
}
I'm compiling it with g++-4.9.2 with [-std=c++11 -O0 -g3 -pedantic -Wall -Wextra -Wconversion] and getting error: uninitialized const member in ‘struct Bar<Foo>’. This is pretty obvious.
BUT try just add std::string as Foo member and program compiles!
#include <string>
struct Foo {
std::string test;
};
// (...)
What happening? Replacing test's type into double causes program to fail to compile again. What string member changes in class?
Link to online compiler with this snippet.
It seems that gcc behaves like that since version 4.6.