vendredi 20 août 2021

inconsistent warning / errors with curly braces narrowing assignment

int g_i;
int truncate (float f) {
    g_i = int{f};           // this is a warning ??
    g_i = int{7.0f};        // this is an error ??
    g_i = int{7.2f};        // error, I can live with that.
}

Why the first one is only a warning and not an error? Or why the second one is not a warning?

Aucun commentaire:

Enregistrer un commentaire