This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/80259] [5/6/7 Regression] ICE deleting friend function


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

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2017-03-30
                 CC|                            |jakub at gcc dot gnu.org,
                   |                            |jason at gcc dot gnu.org
   Target Milestone|---                         |5.5
     Ever confirmed|0                           |1

--- Comment #1 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Started with r213974.
Before that we've rejected it with:
pr80259.C:5:23: error: can’t initialize friend function ‘foo’
   friend void foo() = delete;
                       ^
clang++ gives:
pr80259.C:5:15: error: inline declaration of 'foo' follows non-inline
definition
  friend void foo() = delete;
              ^
pr80259.C:1:6: note: previous definition is here
void foo() {}
     ^

So, what diagnostics would be best here?  What about:
void foo();
struct A
{
  friend void foo() = delete;
};
void foo() {}
?  With/without the first declaration we emit:
pr80259-2.C: In function ‘void foo()’:
pr80259-2.C:6:6: error: redefinition of ‘void foo()’
 void foo() {}
      ^~~
pr80259-2.C:4:15: note: ‘void foo()’ previously defined here
   friend void foo() = delete;
               ^~~
which looks fine to me.  So is the #c0 testcase a redefinition of the function
that should be diagnosed the same way?
For
void foo() {}
inline void foo () {}
we emit:
pr80259-3.C: In function ‘void foo()’:
pr80259-3.C:2:13: error: redefinition of ‘void foo()’
 inline void foo () {}
             ^~~
pr80259-3.C:1:6: note: ‘void foo()’ previously defined here
 void foo() {}
      ^~~
while clang++ emits:
pr80259-3.C:2:13: error: inline declaration of 'foo' follows non-inline
definition
inline void foo () {}
            ^
pr80259-3.C:1:6: note: previous definition is here
void foo() {}
     ^
so at least for now I'd say we should just emit a normal redefinition message.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]