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

--- Comment #2 from Paolo Carlini <paolo.carlini at oracle dot com> ---
Further reduced below. I think it may be just matter of loosening the
gcc_assert in write_unscoped_enum:

Index: mangle.c
===================================================================
--- mangle.c    (revision 212074)
+++ mangle.c    (working copy)
@@ -875,10 +875,11 @@ write_unscoped_name (const tree decl)
     {
       /* If not, it should be either in the global namespace, or directly
      in a local function scope.  A lambda can also be mangled in the
-     scope of a default argument.  */
+     scope of a default argument or in class scope (c++/61566).  */
       gcc_assert (context == global_namespace
           || TREE_CODE (context) == PARM_DECL
-          || TREE_CODE (context) == FUNCTION_DECL);
+          || TREE_CODE (context) == FUNCTION_DECL
+          || TREE_CODE (context) == RECORD_TYPE);

       write_unqualified_name (decl);
     }

//////////////////////////

template < typename > struct function;

template < typename _Res >
struct function < _Res () >
{
  template < typename _Functor>
  function (_Functor);
};

struct C
{
  template <typename T>
  void foo (T, function < C () > = [] { });
};

void bar ()
{
  C c;
  c.foo (1);
}

Reply via email to