Defect Report #342

Previous Defect Report < - > Next Defect Report

Submitter: Joseph Myers (UK)
Submission Date: 2007-03-24
Source: Joseph Myers <>
Reference Document: ISO/IEC WG14 N1223
Version: 1.4
Date: 2008-09-10
Subject: VLAs and conditional expressions


Consider the code:

    int a, b;
    void *p1(void), *p2(void);
    int c1(void);
    int d1(void);
    int z1(void), z2(void);

      int r = (c1()
               ? (z1(), (int (*)[d1()])p1())
               : (z2(), (int (*)[])p2()))[a][b];
      return r;

The type of the conditional expression involves the size expression d1() that's only evaluated in one part of the expression, and this information is needed to evaluate the array reference even when c1() returns false.

For a more complicated example and discussion see reflector messages 10731-10754. The validity of that more complicated example depends on the interpretation of composite type rules as in DR 340, so this example has been simplified to avoid that problem.

Suggested Technical Corrigendum paragraph 6 at end add "or one of the size specifiers (including the case of a single size specifier where the other array type does not include a size specifier) is not an integer constant expression and is not evaluated during the flow of execution." with a footnote "This case arises where a conditional expression involves a cast to variably modified type or a compound literal of variably modified type."

Committee Discussion (for history only)

Spring 2008

The consensus is that the Note in the previous version of this DR was not accurate and should be removed. The DR should be in Review status

Fall 2008

The consensus at this meeting is that this defect should be linked with defect report 340.

Proposed Committee Response

See defect report 340

Previous Defect Report < - > Next Defect Report