[Bug c++/65043] Expected narrowing conversion during list initialization of bool from double

redi at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Thu Jun 1 11:25:00 GMT 2017


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65043

Jonathan Wakely <redi at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |accepts-invalid
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2017-06-01
     Ever confirmed|0                           |1

--- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> ---
Clang does now:

narrow.cc:9:9: error: type 'double' cannot be narrowed to 'bool' in initializer
list [-Wc++11-narrowing]
    X x{d};
        ^
narrow.cc:9:9: note: insert an explicit cast to silence this issue
    X x{d};
        ^
        static_cast<bool>( )
1 error generated.


And EDG gives:

"narrow.cc", line 9: error: invalid narrowing conversion from "double" to
          "bool"
      X x{d};
          ^

1 error detected in the compilation of "narrow.cc".


More information about the Gcc-bugs mailing list