Skip to content

Commit fad8123

Browse files
author
inostensibl
committed
tccgen: fix void expression side effect regression
From 7e01b20 reduced from an app that builds/runs with gcc or clang.
1 parent 2888e49 commit fad8123

3 files changed

Lines changed: 22 additions & 1 deletion

File tree

‎tccgen.c‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3278,7 +3278,6 @@ static void gen_cast(CType *type)
32783278
dbt_bt = dbt & VT_BTYPE;
32793279
sbt_bt = sbt & VT_BTYPE;
32803280
if (dbt_bt == VT_VOID) {
3281-
vtop->r = vtop->r2 = VT_CONST;
32823281
goto done;
32833282
}
32843283
if (sbt_bt == VT_VOID) {

‎tests/tests2/143_void_expr.c‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#include <stdio.h>
2+
3+
static void f(int x)
4+
{
5+
printf("f(%d)\n", x);
6+
}
7+
8+
int main(void)
9+
{
10+
int count = 0, i = 0;
11+
for (; i < 3; ++i) {
12+
printf("%d\n", i);
13+
(void)(i || (f(i), ++count));
14+
}
15+
printf("count %d\n", count);
16+
return count == 1 ? 0 : 1;
17+
}

‎tests/tests2/143_void_expr.expect‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
0
2+
f(0)
3+
1
4+
2
5+
count 1

0 commit comments

Comments
 (0)