14 Nov 2017 • Preprocessor madness

This code (or similar) compiles and runs with every compiler I tested but one:

#define A( x ) 1
int main() {
	return A(); // -> "return 1;"
}

You can even use x in the macro body and it's fine:

#define A( x ) x + 1
int main() {
	return A(); // -> "return + 1;`
}

The only compiler that does the right thing and rejects this (if the spec says this is ok then the spec is fucked) is of course the AMD shader compiler.