public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/35641] New: ICE on overload of friend function definition inside a class
@ 2008-03-19 18:26 philippe at fornux dot com
2008-03-22 23:52 ` [Bug c++/35641] " fang at csl dot cornell dot edu
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: philippe at fornux dot com @ 2008-03-19 18:26 UTC (permalink / raw)
To: gcc-bugs
The following:
**************
template <typename T>
struct Message
{
friend ostream & operator << (ostream & out, const Message & self)
{
cout << __PRETTY_FUNCTION__ << endl;
return out;
}
};
typedef Message<int> IntMsg;
inline ostream & operator << (ostream & out, const IntMsg & self)
{
cout << __PRETTY_FUNCTION__ << endl;
return out;
}
int main()
{
IntMsg m;
cout << m << endl;
}
Produces:
*********
templateoverload.cpp: In function `std::ostream& operator<<(std::ostream&,
const IntMsg&)':
templateoverload.cpp:33: instantiated from here
templateoverload.cpp:0: internal compiler error: in change_decl_assembler_name,
at cgraph.c:541
Resolved with out-of-class definition:
**************************************
template <typename T>
inline ostream & operator << (ostream & out, const Message<T> & self)
{
cout << __PRETTY_FUNCTION__ << endl;
return out;
}
--
Summary: ICE on overload of friend function definition inside a
class
Product: gcc
Version: 3.4.5
Status: UNCONFIRMED
Severity: critical
Priority: P3
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: philippe at fornux dot com
GCC build triplet: gcc version 3.4.5 (mingw special)
GCC host triplet: Windows XP
GCC target triplet: Mingw
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=35641
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug c++/35641] ICE on overload of friend function definition inside a class
2008-03-19 18:26 [Bug c++/35641] New: ICE on overload of friend function definition inside a class philippe at fornux dot com
@ 2008-03-22 23:52 ` fang at csl dot cornell dot edu
2008-03-29 17:11 ` [Bug c++/35641] [4.1 regression] " reichelt at gcc dot gnu dot org
2008-07-04 16:19 ` jsm28 at gcc dot gnu dot org
2 siblings, 0 replies; 4+ messages in thread
From: fang at csl dot cornell dot edu @ 2008-03-22 23:52 UTC (permalink / raw)
To: gcc-bugs
------- Comment #1 from fang at csl dot cornell dot edu 2008-03-22 23:51 -------
In general, friend injection is not part of the standard, so best practice is
to declare before befriending.
--
fang at csl dot cornell dot edu changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |fang at csl dot cornell dot
| |edu
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=35641
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug c++/35641] [4.1 regression] ICE on overload of friend function definition inside a class
2008-03-19 18:26 [Bug c++/35641] New: ICE on overload of friend function definition inside a class philippe at fornux dot com
2008-03-22 23:52 ` [Bug c++/35641] " fang at csl dot cornell dot edu
@ 2008-03-29 17:11 ` reichelt at gcc dot gnu dot org
2008-07-04 16:19 ` jsm28 at gcc dot gnu dot org
2 siblings, 0 replies; 4+ messages in thread
From: reichelt at gcc dot gnu dot org @ 2008-03-29 17:11 UTC (permalink / raw)
To: gcc-bugs
------- Comment #2 from reichelt at gcc dot gnu dot org 2008-03-29 17:11 -------
Here's a reduced testcase:
=====================================
template<int> struct A
{
friend void foo(const A&)
{
__FUNCTION__;
}
};
inline void foo(const A<0>&)
{
__FUNCTION__;
}
void bar()
{
foo(A<0>());
}
=====================================
The bug is fixed since GCC 4.2.0, as the code is correctly rejected:
bug.cc: In instantiation of 'A<0>':
bug.cc:17: instantiated from here
bug.cc:4: error: redefinition of 'void foo(const A<0>&)'
bug.cc:10: error: 'void foo(const A<0>&)' previously defined here
On the 4.1 branch I still get an ICE, but after the above error message:
bug.cc: In instantiation of 'A<0>':
bug.cc:17: instantiated from here
bug.cc:4: error: redefinition of 'void foo(const A<0>&)'
bug.cc:10: error: 'void foo(const A<0>&)' previously defined here
bug.cc:4: internal compiler error: tree check: expected var_decl or
function_decl or type_decl or template_decl, have error_mark in
tsubst_friend_function, at cp/pt.c:5352
Please submit a full bug report, [etc.]
Since we already rejected the code with GCC 3.1 - 3.3.6 this is a regression.
I don't think anybody will fix this minor problem on the 4.1 branch, though.
Btw, the code was wrongly accepted by GCC 4.0.0 - 4.1.1.
--
reichelt at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |reichelt at gcc dot gnu dot
| |org
Status|UNCONFIRMED |NEW
Ever Confirmed|0 |1
Keywords| |error-recovery, ice-on-
| |invalid-code
Known to fail| |3.4.0 3.4.6 4.0.0 4.1.2
Known to work| |3.1 3.3.6
Last reconfirmed|0000-00-00 00:00:00 |2008-03-29 17:11:11
date| |
Summary|ICE on overload of friend |[4.1 regression] ICE on
|function definition inside a|overload of friend function
|class |definition inside a class
Target Milestone|--- |4.1.3
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=35641
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug c++/35641] [4.1 regression] ICE on overload of friend function definition inside a class
2008-03-19 18:26 [Bug c++/35641] New: ICE on overload of friend function definition inside a class philippe at fornux dot com
2008-03-22 23:52 ` [Bug c++/35641] " fang at csl dot cornell dot edu
2008-03-29 17:11 ` [Bug c++/35641] [4.1 regression] " reichelt at gcc dot gnu dot org
@ 2008-07-04 16:19 ` jsm28 at gcc dot gnu dot org
2 siblings, 0 replies; 4+ messages in thread
From: jsm28 at gcc dot gnu dot org @ 2008-07-04 16:19 UTC (permalink / raw)
To: gcc-bugs
------- Comment #3 from jsm28 at gcc dot gnu dot org 2008-07-04 16:18 -------
Closing 4.1 branch.
--
jsm28 at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
Known to fail|3.4.0 3.4.6 4.0.0 4.1.2 |3.4.0 3.4.6 4.0.0 4.1.2
| |4.1.3
Known to work|3.1 3.3.6 |3.1 3.3.6 4.2.0
Resolution| |FIXED
Target Milestone|4.1.3 |4.2.0
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=35641
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2008-07-04 16:19 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-03-19 18:26 [Bug c++/35641] New: ICE on overload of friend function definition inside a class philippe at fornux dot com
2008-03-22 23:52 ` [Bug c++/35641] " fang at csl dot cornell dot edu
2008-03-29 17:11 ` [Bug c++/35641] [4.1 regression] " reichelt at gcc dot gnu dot org
2008-07-04 16:19 ` jsm28 at gcc dot gnu dot org
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).