Title
Commas in controlling expression of conditional inclusion
Status
open
Section
15.2 [cpp.cond]
Submitter
Shafik Yaghmour

Created on 2025-03-24.00:00:00 last changed 1 week ago

Messages

Date: 2025-03-15.00:00:00

Additional notes (March, 2025)

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

Date: 2025-03-24.00:00:00

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?

History
Date User Action Args
2025-03-25 13:43:17adminsetmessages: + msg8005
2025-03-24 00:00:00admincreate