aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorlemon <lsof@mailbox.org>2026-03-05 18:15:21 +0100
committerlemon <lsof@mailbox.org>2026-03-05 18:15:21 +0100
commit1ec29c2bb4350d09ee34b8eff53b9974fcc0a81f (patch)
tree2f7cb8ba209586b929944961719be397bb28760c
parent7b80f232f2a36dff8335335295d681b7e90baaa6 (diff)
c: do not try to eval conditional expression's not taken branch
-rw-r--r--c/eval.c2
-rw-r--r--test/09-init.c2
2 files changed, 2 insertions, 2 deletions
diff --git a/c/eval.c b/c/eval.c
index dc75607..e2d67d7 100644
--- a/c/eval.c
+++ b/c/eval.c
@@ -338,8 +338,6 @@ eval(struct expr *ex, enum evalmode mode)
}
if (ex->t == ECOND) {
if (!eval(&ex->sub[0], mode) || ex->sub[0].t != ENUMLIT) return 0;
- if (!eval(&ex->sub[1], mode)) return 0;
- if (!eval(&ex->sub[2], mode)) return 0;
*ex = ex->sub[!ex->sub[0].u + 1];
return eval(ex, mode);
}
diff --git a/test/09-init.c b/test/09-init.c
index dd9d2a3..6099a4d 100644
--- a/test/09-init.c
+++ b/test/09-init.c
@@ -59,6 +59,8 @@ void f() {
void *rec[1] = {rec+1};
+int static_eval = sizeof(char[ 1 ? 1 : 0/0]);
+
int printf(char *, ...);
int main() {
printf("gexplicit[4] -> %d,%d,%d,%d\n", gexplicit[0], gexplicit[1], gexplicit[2], gexplicit[3]);