Movatterモバイル変換


[0]ホーム

URL:


Issue 1816 - WG21 CWG Issues
Title
Unclear specification of bit-field values
Status
cd4
Section
7.3.9 [conv.integral]
Submitter
Hubert Tong

Created on2013-12-02.00:00:00 last changed109 months ago

Messages

msg5337 (view)
Date: 2014-11-15.00:00:00

[Moved to DR at the November, 2014 meeting.]

msg4805 (view)
Date: 2014-02-15.00:00:00

Proposed resolution (February, 2014):

  1. Change 7.3.9 [conv.integral] paragraph 3 as follows:

  2. If the destination type is signed, the value is unchanged if it can berepresented in the destination type(and bit-field width);otherwise, the value is implementation-defined.
  3. Change 7.6.1.6 [expr.post.incr] paragraph 1 as follows:

  4. ...The result is a prvalue. The type of the result is the cv-unqualifiedversion of the type of the operand.If the operand is a bit-field thatcannot represent the incremented value, the resulting value of thebit-field is implementation-defined. See also7.6.6 [expr.add] and 7.6.19 [expr.assign].
  5. Change 7.6.19 [expr.assign] paragraph 6 as follows:

  6. When the left operand of an assignment operatordenotes a referencetoT, the operation assigns to the object of typeTdenoted by the referenceis a bit-field that cannot representthe value of the expression, the resulting value of the bit-field isimplementation-defined..
  7. Change the final bullet of 9.5 [dcl.init] paragraph 17as follows:

  8. The semantics of initializers are as follows...

    • ...

    • ...no user-defined conversions are considered. If the conversioncannot be done, the initialization is ill-formed.When initializing abit-field with a value that it cannot represent, the resulting value of thebit-field is implementation-defined. [Note: An expression oftype...

msg4755 (view)
Date: 2013-12-02.00:00:00

7.3.9 [conv.integral] paragraph 3 says, regarding integralconversions,

If the destination type is signed, the value is unchanged ifit can be represented in the destination type (and bit-fieldwidth); otherwise, the value is implementation-defined.

The values that can be represented in a bit-field are notwell specified, except for the correspondence with the values ofan enumeration in 9.8.1 [dcl.enum]. In particular, it isnot clear whether a bit-field has a sign bit and whether bit-fieldsmay have padding bits.

Another point to note in this wording: paragraph 1 describesthe context as

A prvalue of an integer type can be converted to a prvalueof another integer type.

However, prvalues cannot be bit-fields, so the applicability ofthe mention of “bit-field width” in paragraph 3 isunclear.

History
DateUserActionArgs
2017-02-06 00:00:00adminsetstatus: drwp -> cd4
2015-05-25 00:00:00adminsetstatus: dr -> drwp
2015-04-13 00:00:00adminsetmessages: +msg5337
2014-11-24 00:00:00adminsetstatus: ready -> dr
2014-03-03 00:00:00adminsetmessages: +msg4805
2014-03-03 00:00:00adminsetstatus: open -> ready
2013-12-02 00:00:00admincreate

[8]ページ先頭

©2009-2026 Movatter.jp