This is an unofficial snapshot of the ISO/IEC JTC1 SC22 WG21 Core Issues List revision 117a. See http://www.open-std.org/jtc1/sc22/wg21/ for the official list.

2025-04-13


3017. Commas in controlling expression of conditional inclusion

Section: 15.2  [cpp.cond]     Status: open     Submitter: Shafik Yaghmour     Date: 2025-03-24

Consider:

  #if 1 ? 1, 0: 3
  #error
  #endif

Is this a well-formed translation unit?

According to 15.2 [cpp.cond] paragraph 10, C23 6.10.2 paragraph 3 and C23 6.6, the controlling expression is required to be a syntactic constant-expression (7.7 [expr.const]). (Concerns about C++ expressions vs. C expressions are handled via issue 1436.)

However, implementations uniformly reject the example (gcc and clang only in pedantic mode), because a comma operator appears in the controlling expression. There is no apparent normative basis for the rejection.

Do all implementations have the same bug, or do both C and C++ share the same specification hole?

Additional notes (March, 2025)

Forwarded to SG22 via paper issue #2294, by decision of the CWG chair.