Which modern compilers support the Gnu Statement expression (C and C++ languages). What versions should I have to use a statement expressions?
Statement expression i
As said in the comment of my previous answer, the Intel Compiler does support the statement expressions. But the emulation by Intel of that GNU extension is not complete, in C++. The following code is taken from CGAL-4.0 (http://www.cgal.org/):
#include <cassert>
struct A {
int* p;
A(int i) : p(new int(i)) {}
~A() { delete p; }
int value() const { return *p;}
};
int main()
{
int i = __extension__ ({ int j = 2; j+j; });
assert(i == 4);
// The Intel Compiler complains with the following error:
// "error: destructible entities are not allowed inside of a statement
// expression"
// See http://software.intel.com/en-us/articles/cdiag1487/
i = __extension__ ({ A a(2); A b(3); a.value() + b.value(); });
assert(i == 5);
return 0;
}
A comment in the code even give the error returned by the Intel Compiler, tested with version 11, 12, or 13.
http://software.intel.com/en-us/articles/cdiag1487/
The Intel C++ Compiler does not support statement expressions, even the last version that I know, version 13.0.
The PathScale® EKOPath Compiler Suite
It support gnu99 with "−std=gnu99"