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

--- Comment #4 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Jakub Jelinek <[email protected]>:

https://gcc.gnu.org/g:6341d34747a6ac554e70ec1e0e39f1bece3506d3

commit r17-4856-g6341d34747a6ac554e70ec1e0e39f1bece3506d3
Author: Jakub Jelinek <[email protected]>
Date:   Sat Oct 3 21:29:06 2026 +0200

    c++: Fix up mangling of __builtin_{bswap,bitreverse}g calls [PR127668]

    The following testcases ICE during mangling, the dependent
    __builtin_{bswap,bitreverse}g calls (where those identifiers
    we treat as keywords and don't even have such builtins,
    given that those are the first type-generic builtins with the
    return type dependent on the argument type(s)) are emitted
    as internal fn calls (IFN_BSWAP or IFN_BITREVERSE), and
    during mangling we just ICE on any calls to internal functions.

    The following patch mangles those 2 calls like we mangle e.g.
    template <typename T>
    auto foo (T t) -> decltype (__builtin_popcountg (t)) { return t; }

    template int foo <unsigned> (unsigned);
    - _Z3fooIjEDTcl19__builtin_popcountgfp_EET_ .  In
    that case it is a type-generic builtin with a fixed return
    type and we trigger the
      /* Mangle a dependent name as the name, not whatever happens to
         be the first function in the overload set.  */
      if (OVL_P (fn)
          && type_dependent_expression_p_push (expr))
        fn = OVL_NAME (fn);
    case in the CALL_EXPR write_expression handling, so fn is
    then an identifier.

    2026-10-03  Jakub Jelinek  <[email protected]>

            PR c++/127668
            * mangle.cc (write_expression): Handle mangling of
            calls to IFN_BSWAP and IFN_BITREVERSE.

            * g++.dg/ext/builtin-bswapg-1.C: New test.
            * g++.dg/ext/builtin-bitreverseg-1.C: New test.

    Reviewed-by: Jason Merrill <[email protected]>

Reply via email to