Skip to content

#if: &&, || and ?: short-circuit #722

Closed

Description

@danmar

In #if, the operand that is not evaluated must not cause an error (C11 6.5.13–6.5.15, used by 6.10.1).

#if 0 && (1/0)
#endif

gcc: no error, condition is false.
simplecpp: syntax error: failed to evaluate #if condition, division/modulo by zero

#if expression gcc simplecpp
0 && (1/0) false error: division/modulo by zero
1 || (1/0) true error: division/modulo by zero
1 ? 2 : (1/0) true error: division/modulo by zero

Activity

  1. added 3 commits that reference this issue on Nov 6, 2026
    e5e3610
    1d63864
    17f8cf8
  2. added a commit that references this issue on Nov 9, 2026
    45de9af
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions