Date
2008-08-15.00:00:00
Message id
1749

Content

Proposed resolution (August, 2008):

  1. Delete bullet 6 of 7.7 [expr.const] paragraph 2:

    • a type conversion from a floating-point type to an integral type (7.3.11 [conv.fpint]) unless the conversion is directly applied to a floating-point literal;
  2. Add a new paragraph after 7.7 [expr.const] paragraph 3:

  3. [Note: Although in some contexts constant expressions must be evaluated during program translation, others may be evaluated during program execution. Since this International Standard imposes no restrictions on the accuracy of floating-point operations, it is unspecified whether the evaluation of a floating-point expression during translation yields the same result as the evaluation of the same expression (or the same operations on the same values) during program execution. [Footnote: Nonetheless, implementations are encouraged to provide consistent results, irrespective of whether the evaluation was actually performed during translation or during program execution. —end footnote] [Example:

      bool f() {
        char array[1 + int(1 + 0.2 - 0.1 - 0.1)];  // Must be evaluated during translation
        int size = 1 + int(1 + 0.2 - 0.1 - 0.1);   // May be evaluated at runtime
        return sizeof(array) == size;
      }
    

    It is unspecified whether the value of f() will be true or false. —end example] —end note]