[Bug c++/107442] New: Concept and Template Var mangling

nathan at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Thu Oct 27 18:12:11 GMT 2022


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

            Bug ID: 107442
           Summary: Concept and Template Var mangling
           Product: gcc
           Version: 13.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: nathan at gcc dot gnu.org
  Target Milestone: ---

>From a discussion re clang's mangling
(https://github.com/llvm/llvm-project/issues/58197), I find some GCC cases

namespace Concept { template<typename> concept True = true; }
namespace Struct_ { template<typename> struct True {}; }
namespace Var____ { template<typename> constexpr bool True = true; }
namespace Functio { template<typename> void True (); }

template <bool> struct ImplExpr { template <typename T> using Type = T; };
template <typename> struct ImplType { template <typename T> using Type = T; };
template <void ()> struct ImplFunc { template <typename T> using Type = T; };

template <bool C, typename T> using IfExpr
  = typename ImplExpr<C>::template Type<T>;
template <typename C, typename T> using IfType
  = typename ImplType<C>::template Type<T>;
template <void C (), typename T> using IfFunc
  = typename ImplFunc<C>::template Type<T>;

template<typename T> using TypeConcept = IfExpr<Concept::True<T>, T>;
template<typename T> using TypeStruct_ = IfType<Struct_::True<T>, T>;
template<typename T> using TypeVar____ = IfExpr<Var____::True<T>, T>;
template<typename T> using TypeFunctio = IfFunc<Functio::True<T>, T>;

template<typename T> TypeConcept<T> fConcept () {return {};}
template<typename T> TypeStruct_<T> fStruct_ () {return {};}
template<typename T> TypeVar____<T> fVar____ () {return {};}
template<typename T> TypeFunctio<T> fFunctio () {return {};}

int main ()
{
  fConcept<int> ();
  fStruct_<int> ();
  fVar____<int> ();
  fFunctio<int> ();
}

neroon:270>./cc1plus -quiet -std=c++20 conc2.cc -o - | grep '^_Z'
_Z8fConceptIiEN8ImplExprIX4TrueIT_EEE4TypeIS1_EEv:
_Z8fStruct_IiEN8ImplTypeIN7Struct_4TrueIT_EEE4TypeIS3_EEv:
_Z8fVar____IiEN8ImplExprIX4TrueIT_EEE4TypeIS1_EEv:
_Z8fFunctioIiEN8ImplFuncIX4TrueIT_EEE4TypeIS1_EEv:
_ZN7Var____4TrueIiEE:

neroon:270>clang++ -S -std=c++20 conc2.cc -o - | grep '^_Z'      
_Z8fConceptIiEN8ImplExprIL_ZN7Concept4TrueIT_EEEE4TypeIS3_EEv: #
@_Z8fConceptIiEN8ImplExprIL_ZN7Concept4TrueIT_EEEE4TypeIS3_EEv
_Z8fStruct_IiEN8ImplTypeIN7Struct_4TrueIT_EEE4TypeIS3_EEv: #
@_Z8fStruct_IiEN8ImplTypeIN7Struct_4TrueIT_EEE4TypeIS3_EEv
_Z8fVar____IiEN8ImplExprIXsr7Var____E4TrueIT_EEE4TypeIS1_EEv: #
@_Z8fVar____IiEN8ImplExprIXsr7Var____E4TrueIT_EEE4TypeIS1_EEv
_Z8fFunctioIiEN8ImplFuncIXsr7FunctioE4TrueIT_EEE4TypeIS1_EEv: #
@_Z8fFunctioIiEN8ImplFuncIXsr7FunctioE4TrueIT_EEE4TypeIS1_EEv

We're dropping the scoping off Concept::True<T> and Var____::True<T> &
Functio::True<T> (we're representing these as TEMPLATE_ID_EXPRs, and the
mangler only expects an unqualified function there).  Should we represent these
using ScopeRef, like clang does for the variable case (the clang issue is what
should it do for the concept case).  Or should we mangle both concept and var
as a template instantiation like the class case?


More information about the Gcc-bugs mailing list