Consider following program: (see live demo here.)
#include <iostream>
inline double fun()
{
return 3.0;
}
extern double m;
double d2=m;
int main()
{
std::cout<<d2;
}
double m=fun();
I was expecting to get output of program as 3.0 but it gives me output 0. Why?
It looks like variable d2 is initialized statically?
Shouldn't it be initialized dynamically?
I've tested it on g++ 4.8.1, 4.9.2 & MSVS 2010 & get 0 as an output.