[Bug libstdc++/92057] variant converting constructor fails for primitives
redi at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Mon Oct 14 11:18:00 GMT 2019
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92057
--- Comment #6 from Jonathan Wakely <redi at gcc dot gnu.org> ---
Because the Double(int) constructor takes an int, and so passing it an int is
not a narrowing conversion.
Try defining that constructor differently and you'll get a warning about a
narrowing conversion inside the constructor:
prog.cc: In constructor 'Double::Double(int)':
prog.cc:7:23: warning: narrowing conversion of 'i' from 'int' to 'double'
[-Wnarrowing]
7 | Double(int i) : x{i} {}
| ^
More information about the Gcc-bugs
mailing list