1
int x = ({
    int y = 10, z;
    if (2>1) {
        z = 11;
    }
    y+z;
});

x will be 21. What is this syntax? I've seen it in C and I'm guessing it also exists in C++. Is this standard in either language?

1 Answers1

6

This is a non-standard gcc compiler extension, that lets arbitrary code get executed in an expression context and produce an expression result.

Sam Varshavchik
  • 114,536
  • 5
  • 94
  • 148