When compiling this code:
enum B: bool { T = true };
struct A { bool member; };
void foo(const B b = T)
{
A a{b}; // warning here
}
void bar()
{
const B b = T;
A a{b};
}
MSVC issues a warning in foo:
warning C4838: conversion from 'const B' to 'bool' requires a narrowing conversion
but compiles bar fine.
Here is a proof
Is it a compiler bug or intended behavior?
Aucun commentaire:
Enregistrer un commentaire