https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84707
--- Comment #4 from Marek Polacek <mpolacek at gcc dot gnu.org> --- It really seems all we need is --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -1410,7 +1410,9 @@ duplicate_decls (tree newdecl, tree olddecl, bool newdecl_is_friend) || TREE_TYPE (olddecl) == error_mark_node) return error_mark_node; - if (UDLIT_OPER_P (DECL_NAME (newdecl)) + if (DECL_NAME (newdecl) + && DECL_NAME (olddecl) + && UDLIT_OPER_P (DECL_NAME (newdecl)) && UDLIT_OPER_P (DECL_NAME (olddecl))) { if (TREE_CODE (newdecl) == TEMPLATE_DECL then we give a nice error: 84707.C:5:1: error: ‘namespace { }’ conflicts with a previous declaration namespace {} ^~~~~~~~~ 84707.C:1:8: note: previous declaration ‘namespace { }’ inline namespace { ^~~~~~~~~