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

2024-04-18


1461. Narrowing conversions to bit-fields

Section: 9.4.5  [dcl.init.list]     Status: NAD     Submitter: Richard Corden     Date: 2012-02-08

The definition of a “narrowing conversion” in 9.4.5 [dcl.init.list] paragraph 7 is couched in terms of the type of the target. A conversion to a too-small bit-field should presumably also be categorized as a narrowing conversion. (See also issue 1449.)

Additional note (August, 2012):

It was observed that the proposed narrowing error, unlike in other contexts, cannot be circumvented by adding a cast. The only way to avoid a narrowing error would be to avoid using the brace syntax or to mask the value to an appropriate width. Even the latter approach could conceivably require an implementation to track the maximum number of bits needed by operations applied on top of the masked value, unless the masking were required to be at the top level of the initializer expression.

Rationale (October, 2012):

CWG felt that this was more of a language design question and would be better considered by EWG.

Rationale (February, 2014):

EWG determined that no action should be taken on this issue.