Skip to Main Content

DevOps, CI/CD and Automation

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Studio 12.6 "narrowing conversion from bool to unsigned"

kovalJan 15 2018 — edited Jan 16 2018

Studio 12.6 is inconsistent about uniform initialization from bool to unsigned types.

bool b;

unsigned u{b};

int i{b};

test.cpp, line 2: Error: Narrowing conversion of 'bool' value to 'unsigned' is not allowed here.

1 Error(s) detected.

Same goes with short and long types.
As the standard dictates, narrowing conversion from a non-constant integral only happens if destination type cannot represent all the values of the original type. Obviously all integer types are able to represent 0 and 1 and this is a bug in CC

Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Feb 13 2018
Added on Jan 15 2018
3 comments
272 views