Skip to content

Commit

Permalink
Merge pull request cc65#2521 from kugelfuhr/kugelfuhr/fix-2520
Browse files Browse the repository at this point in the history
Fix wrong evaluation of ternary expressions in the preprocessor
  • Loading branch information
mrdudz authored Sep 15, 2024
2 parents 7dc09fd + 175ec65 commit 16258d8
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/cc65/ppexpr.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 4 additions & 0 deletions test/val/bug2520.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#if (1 ? 2 : 0) != 2
#error
#endif
int main() { return 0; }

0 comments on commit 16258d8

Please sign in to comment.