Hi,
Following code should be rejected by C compiler:
#include <stdio.h>
int main(void)
{
int arr[] = {0};
(1, arr[0]) = 30; // <--- illegal
printf("%d\n", arr[0]);
return 0;
}
but tcc accepts it as the result of `(1, arr[0])` becomes an lvalue (should be rvalue instead):
$ tcc main.c
$ ./a.out
30
For comparison, gcc rejects it with following message:
$ gcc main.c
main.c: In function ‘main’:
main.c:6:21: error: lvalue required as left operand of assignment
6 | (1, arr[0]) = 30;
| ^
My environment:
$ tcc --version
tcc version 0.9.28rc 2024-10-27 mob@a21b5f1f (x86_64 Linux)
$ git log -1
commit a21b5f1fd7eda4f8b23ed5c5cc3f6ead748401db (HEAD -> mob, origin/mob, origin/HEAD)
$ uname -srmo
Linux 6.11.6-arch1-1 x86_64 GNU/Linux
For more references, links to the standard and comparisons with other compilers, please see following SO thread (I made it just before reporting this bug):
https://stackoverflow.com/questions/79171822/is-expession-lvalue-rvalue-a-valid-assignment-in-c-or-c-why-do-some-cBest Regards,
Kornel