https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66007
--- Comment #9 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
(In reply to Paolo Carlini from comment #8)
> Index: typeck2.c
> ===================================================================
> --- typeck2.c (revision 222767)
> +++ typeck2.c (working copy)
> @@ -959,10 +959,10 @@ check_narrowing (tree type, tree init, tsubst_flag
> else if (complain & tf_error)
> {
> global_dc->pedantic_errors = 1;
> - if (!pedwarn (EXPR_LOC_OR_LOC (init, input_location), OPT_Wnarrowing,
> - "narrowing conversion of %qE from %qT to %qT "
> - "inside { }", init, ftype, type))
> - ok = true;
> + pedwarn (EXPR_LOC_OR_LOC (init, input_location), OPT_Wnarrowing,
> + "narrowing conversion of %qE from %qT to %qT "
> + "inside { }", init, ftype, type);
> + ok = true;
> global_dc->pedantic_errors = flag_pedantic_errors;
> }
> }
Another possibility would be to check if the pedwarn increased errorcount, so
something like:
int savederrorcount = errorcount;
pedwarn (EXPR_LOC_OR_LOC (init, input_location), OPT_Wnarrowing,
"narrowing conversion of %qE from %qT to %qT "
"inside { }", init, ftype, type);
if (errorcount != savederrorcount)
ok = true;