https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99331

--- Comment #9 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-10 branch has been updated by Marek Polacek
<mpola...@gcc.gnu.org>:

https://gcc.gnu.org/g:b281edd801018ed703ce7bb0d49fef59ff8cef8b

commit r10-9688-gb281edd801018ed703ce7bb0d49fef59ff8cef8b
Author: Marek Polacek <pola...@redhat.com>
Date:   Thu Mar 4 20:20:40 2021 -0500

    c++: -Wconversion vs value-dependent expressions [PR99331]

    This PR complains that we issue a -Wconversion warning in

      template <int N> struct X {};
      template <class T> X<sizeof(T)> foo();

    saying "conversion from 'long unsigned int' to 'int' may change value".
    While it's not technically wrong, I suspect -Wconversion warnings aren't
    all that useful for value-dependent expressions.  So this patch disables
    them.  This is a regression that started with r241425:

    @@ -7278,7 +7306,7 @@ convert_template_argument (tree parm,
              val = error_mark_node;
            }
        }
    -      else if (!dependent_template_arg_p (orig_arg)
    +      else if (!type_dependent_expression_p (orig_arg)
               && !uses_template_parms (t))
        /* We used to call digest_init here.  However, digest_init
           will report errors, which we don't want when complain

    Here orig_arg is SIZEOF_EXPR<T>; dependent_template_arg_p (orig_arg) was
    true, but type_dependent_expression_p (orig_arg) is false so we warn in
    convert_nontype_argument.

    gcc/cp/ChangeLog:

            PR c++/99331
            * call.c (build_converted_constant_expr_internal): Don't emit
            -Wconversion warnings.

    gcc/testsuite/ChangeLog:

            PR c++/99331
            * g++.dg/warn/Wconversion5.C: New test.

    (cherry picked from commit 9efd72d28956eb79c7fca38e3c959733a3bb25bb)

Reply via email to