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; }