SolarisStudio considers 'auto' to be a storage class specifier in C++98 mode (as appropriate), and considers variables without a specified type to be of type int. So, it treats auto x = 3.14; as auto int x = 3.14; which in C++98 mode is equivalent to int x = 3.14; and it does not fail to compile as expected. Change the test to use a reference so that the type must be known.
13 lines
95 B
C++
13 lines
95 B
C++
|
|
double foo_ = 3.14;
|
|
|
|
double& foo()
|
|
{
|
|
return foo_;
|
|
}
|
|
|
|
void someFunc()
|
|
{
|
|
auto& x = foo();
|
|
}
|