Hi,
As far as I'm concerned you couldn't ignore the warning generated by the compiler. Here the compiler will generate Compiler Warning (level 1) C4838 .
In general, for violations of the language rules, the C++ standard requires that the compiler issue a diagnostic. It did that. The Standard specifies that a diagnostic is required in case that a program is ill-formed. Which is the case when a narrowing-conversion takes place inside a braced-initializer.
According to the Doc: Implicit type conversions
If the selected conversion is a promotion, the compiler does not issue a warning. If the conversion is a narrowing, the compiler issues a warning about possible data loss. Whether actual data loss occurs depends on the actual values involved, but we recommend that you treat this warning as an error.
Best Regards,
Jeanine Zhang
If the response is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.