The following code compiles with G++ 4.6.1, but not with Visual Studio 2008
return (m_something == 0) ?
throw std::logic_error("Something wrong happened") : m_something;
The fact is the Visual Studio compiler performs an internal crash.
I want to know if this is standard C++ and why it doesn’t compile with Visual Studio, but does with G++?
It is standard C++. Either (or both) of the then/else expressions in a conditional expression is allowed to be a throw-expression instead (C++98 5.16/2).
If Visual Studio crashes when compiling it… that would seem to be unfortunate!