This is a tricky question because it is a stress test for the compiler preprocessor.
Depending on whether the preprocessor is an integrated phase of the compiler or a separate program that passes its output to the compiler via a file or a channel, in which case, is it enough to not insert the marker incorrectly, you can get the expected result: 5 or you may get a compilation error.
After the pre-processed contents of stdio.h processed, the source code extends to:
int main() { printf("The value of A is %d\n", --5); return 0; }
But two are separate tokens, so depending on whether the preprocessor separates them at its output or not, you can get a program that outputs 5 or one that does not compile, because -- it cannot be applied to the letter 5 .
Both the gcc and clang preprocessors behave correctly and share - with extra space to prevent marker insertion when they produce the preprocessor using the -E command line -E . They output this as pre-processed source code after the extension <stdio.h> :
int main() { printf("The value of A is %d\n", - -5); return 0; }
Try your own compiler to see how it extends the source code. It seems that Visual Studio 2013 and 2015 did not pass the test and rejected the program with an error.
To make everything clear, I am not saying that the behavior of a program should depend on the architecture of the compiler. I was hoping that at least one common C compiler would not apply this conformance test. I am not surprised that MS Visual Studio 2013 and 2015 did not pass this test.
Additional space is needed only in the text output of the preprocessor. It does not matter whether Visual Studio uses several separate phases or not, the source program is absolutely correct and their compilation failure is an error.
chqrlie
source share