On 2018-02-03 04:52 AM, Robert P. J. Day wrote: > > currently rewriting my C++ courses from some time back, and wanted > to demonstrate a simply narrowing error; to wit: > > int > main() > { > bool b1 {true}; > bool b2 {false}; > bool b3 {7}; // narrowing error? > > int i {42}; > int j {42.1}; // narrowing error? > } > > oddly, if i use "clang -std=c++11 narrow.cpp", both of those > narrowing conversions are flagged, but if i use "g++ -std=c++11 > narrow.cpp", only the second is flagged -- g++ seems fine with > narrowing an int to a bool, even though stroustrup's book on C++11 > clearly suggests that should be an error as long as one uses C++ style > curly brace initialization: > > bool b1 = 7; // 7!=0, so b becomes true > bool b2 {7}; // error : narrowing (§2.2.2, §10.5) > > any C++ wizards out there want to comment on this? It's a known bug. I'd link you to the bugzilla report but gnu.org always gives a 403 if you try to connect from any IP address in an Xplornet block.. -- Stephen M. Webb <stephen [ dot ] webb [ at ] bregmasoft [ dot ] ca>