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} {}
      |                       ^

Reply via email to