In my work somebody did produce a code which is reduced as follow:
int main()
{
int a[20];
a[3, 4];
return 0;
}
the a[3, 4] compile without error and without warning on default gcc option. With gcc -Wall option it produce the following warning:
test.c: In function ‘main’:
test.c:4:8: warning: left-hand operand of comma expression has no effect [-Wunused-value]
a[3, 4];
^
test.c:4:5: warning: statement with no effect [-Wunused-value]
a[3, 4];
^
I can also compile on clang.
Basically, i dont understand why this is compiling ? And what it is actually doing (i know a[3,4] return a pointer but that is all i understand). I have tried to look at the assembly code with the -S gcc option but i dont really understand its output (lack of x86 assembly knowledge).
EDIT: it actually does not return a pointer but a integer (mistake on my part)