tccgen: fix void expression side effect regression

From 7e01b20362

reduced from an app that builds/runs with gcc or clang.
This commit is contained in:
inostensibl
2026-05-09 21:49:37 -04:00
parent 2888e49f39
commit fad812360b
3 changed files with 22 additions and 1 deletions

View File

@@ -3278,7 +3278,6 @@ again:
dbt_bt = dbt & VT_BTYPE;
sbt_bt = sbt & VT_BTYPE;
if (dbt_bt == VT_VOID) {
vtop->r = vtop->r2 = VT_CONST;
goto done;
}
if (sbt_bt == VT_VOID) {

View File

@@ -0,0 +1,17 @@
#include <stdio.h>
static void f(int x)
{
printf("f(%d)\n", x);
}
int main(void)
{
int count = 0, i = 0;
for (; i < 3; ++i) {
printf("%d\n", i);
(void)(i || (f(i), ++count));
}
printf("count %d\n", count);
return count == 1 ? 0 : 1;
}

View File

@@ -0,0 +1,5 @@
0
f(0)
1
2
count 1