[cfe-dev] Narrowing in initalizer lists

Richard Smith richard at metafoo.co.uk
Fri Oct 14 11:13:02 PDT 2011


On Fri, October 14, 2011 14:08, Christopher Jefferson wrote:
> I just wanted to quickly check this bug (which occurs in boost).
> clang -std=c++0x forbids:
> int f(); unsigned int vals[] = {f(),f()};
> As in initalizer lists, int cannot be narrowed to int.

int cannot be narrowed to *unsigned* int.

> Just wanted to double check, is clang definitely in the right here?

Yes. This is a narrowing conversion, even though the conversion from int to
unsigned int has a well-defined meaning for all values of type int.


More information about the cfe-dev mailing list