[Bug c++/124691] [13/14/15/16/17 Regression] ICE in duplicate_decls with friend function redeclaration in class template

pinskia at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Mon Jun 8 22:50:39 GMT 2026


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

Drea Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|error-recovery,             |ice-on-valid-code
                   |ice-on-invalid-code         |
             Blocks|                            |65608

--- Comment #2 from Drea Pinski <pinskia at gcc dot gnu.org> ---
This can be made into valid by doing:
```

template<int>
struct A{
    friend void f(){}
};

template<int>
struct B{
    friend void f();
};

template struct A<0>;    // define f
template struct B<0>;    // first declaration of f 
template struct B<1>;    // second declaration of f, ICE here

int main(){}
```


Referenced Bugs:

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65608
[Bug 65608] [meta-bug] friend issues


More information about the Gcc-bugs mailing list