From 175ec65af1324ac5f3737c336e7b7b049b777a27 Mon Sep 17 00:00:00 2001 From: Kugel Fuhr <98353208+kugelfuhr@users.noreply.github.com> Date: Sat, 14 Sep 2024 21:12:19 +0200 Subject: [PATCH] Fix #2520. --- src/cc65/ppexpr.c | 2 +- test/val/bug2520.c | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) create mode 100644 test/val/bug2520.c diff --git a/src/cc65/ppexpr.c b/src/cc65/ppexpr.c index 8d8c0b65d..dc6803f91 100644 --- a/src/cc65/ppexpr.c +++ b/src/cc65/ppexpr.c @@ -726,7 +726,7 @@ static void PPhieQuest (PPExpr* Expr) PPhieQuest (&Expr3); /* Set the result */ - Expr->IVal = Expr->IVal ? Expr2.IVal != 0 : Expr3.IVal != 0; + Expr->IVal = Expr->IVal ? Expr2.IVal : Expr3.IVal; /* Restore evaluation as before */ PPEvaluationEnabled = PPEvaluationEnabledPrev; diff --git a/test/val/bug2520.c b/test/val/bug2520.c new file mode 100644 index 000000000..7a216df4d --- /dev/null +++ b/test/val/bug2520.c @@ -0,0 +1,4 @@ +#if (1 ? 2 : 0) != 2 +#error +#endif +int main() { return 0; }