This is the mail archive of the
gcc-prs@gcc.gnu.org
mailing list for the GCC project.
c++/119: Re: Apparant C++ bug in gcc 2.95.2 and latest egcs snapshot
- To: gcc-gnats at gcc dot gnu dot org
- Subject: c++/119: Re: Apparant C++ bug in gcc 2.95.2 and latest egcs snapshot
- From: "Martin v. Loewis" <martin at loewis dot home dot cs dot tu-berlin dot de>
- Date: Fri, 17 Mar 2000 09:55:05 +0100
- References: <Pine.BSF.4.05.10003171903210.17151-200000@jander.fl.net.au>
- Resent-Cc: gcc-prs at gcc dot gnu dot org, hb at fl dot net dot au
- Resent-Reply-To: gcc-gnats@gcc.gnu.org, "Martin v. Loewis" <martin@loewis.home.cs.tu-berlin.de>
>Number: 119
>Category: c++
>Synopsis: -fno-default-inline broken
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: unassigned
>State: analyzed
>Class: wrong-code
>Submitter-Id: net
>Arrival-Date: Fri Mar 17 01:06:01 PST 2000
>Closed-Date:
>Last-Modified:
>Originator: Nicholas Vinen <hb@fl.net.au>
>Release: 2.95.2
>Organization:
>Environment:
>Description:
Date: Fri, 17 Mar 2000 19:04:17 +1100 (EST)
Original-Message-ID: <Pine.BSF.4.05.10003171903210.17151-200000@jander.fl.net.au>
OK, code is included. If this isn't a bug, it's definately
strange.
Compile the program. It compiles fine.
Now try compiling with -fno-default-inline. It compiles but fails
to link. If you add "inline" to that friend operator definition on line
50, it works.
It seems to me, it shouldn't matter if a function is declared
inline or not whether the code links... I don't know why the person that
wrote this code declared the operator that way but it seems to work under
all circumstances but this with this and other compilers. For now I'll
declare it inline, hopefully you can work out why it's doing this so I
don't have to.
Nicholas Vinen
>How-To-Repeat:
template <class TYPE>
class TPoint
{
public:
TPoint(TYPE x, TYPE y)
{
this->x = x;
this->y = y;
}
TYPE x, y;
TPoint<TYPE> operator-() const { TPoint<TYPE> tReturn(-x,-y); return tReturn; };
};
template <class TYPE>
class TRect
{
public:
TRect()
{
}
TRect(TYPE left, TYPE top, TYPE right, TYPE bottom)
{
this->left = left;
this->top = top;
this->right = right;
this->bottom = bottom;
}
TYPE left, top, right, bottom;
TPoint<TYPE> UpperLeft() const { return TPoint<TYPE>(left, top); };
template <class OTHERTYPE>
void Translate( OTHERTYPE x, OTHERTYPE y )
{
left += (TYPE)x;
right += (TYPE)x;
top += (TYPE)y;
bottom += (TYPE)y;
}
template <class OTHERTYPE>
void Translate(const TPoint<OTHERTYPE> pt)
{
Translate(pt.x, pt.y);
}
friend TRect<TYPE> operator-( const TRect<TYPE>& rc, const TPoint<TYPE>& pt ){ TRect<TYPE> trc(rc); trc.Translate(-pt); return trc; };
__inline TRect AreaRect() const
{
return *this - UpperLeft();
}
};
int main(void)
{
TRect<int> a(0,0,10,10);
TRect<int> area;
area = a.AreaRect();
return 0;
}
>Fix:
>Release-Note:
>Audit-Trail:
>Unformatted: