Narrowing in initalizer lists

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.

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

for those keeping track I run the 'minion-' boost testers, which are checking clang both without 0x and with libc++ with and without 0x (0x without libc++ fails for many reasons inside libstdc++, for non-interesting reasons).

For people who want to look at reasons for libc++ and 0x failures, feel free. I may try to categorise them. Some of them look easy (missing std:: or boost:: quanlifications). The problems in icl are due to bugs in that library, that don't seem to be getting fixed.

I am already investigating one issue (floating point parsing of terms like 0x0).

Chris

Yes. int -> unsigned int is a narrowing conversion, and thus forbidden in this context.

Sebastian

Hi,

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.

Richard