Thread overview | ||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
December 01, 2006 [8.50.1n] another bug | ||||
---|---|---|---|---|
| ||||
This code fails on 8.50.1n while it works with Comeau and looks well formed. It is triggered by the friend declaration. ----------------------- template <class T> struct addable2 { friend T operator +( T lhs, const T& rhs ) { return lhs += rhs; } }; template<class T> struct addable : addable2<T> { }; template <class T> class point : addable< point<T> > { }; int main() { point<int> ppp; return 0; } ---------------------------- This bug manifests itself when <boost/operators.hpp> is used. /Pavel |
December 01, 2006 Re: [8.50.1n] another bug | ||||
---|---|---|---|---|
| ||||
Posted in reply to Pavel Vozenilek | Thanks! |
December 12, 2006 Re: [8.50.1n] another bug | ||||
---|---|---|---|---|
| ||||
Posted in reply to Pavel Vozenilek |
> -----------------------
> template <class T>
> struct addable2
> {
> friend T operator +( T lhs, const T& rhs ) { return lhs += rhs; }
> };
>
>
> template<class T>
> struct addable : addable2<T>
> {
> };
>
> template <class T>
> class point : addable< point<T> >
> {
> };
>
> int main()
> {
> point<int> ppp;
> return 0;
> }
> ----------------------------
>
I'd checked the code against 8.50.2 beta.
The previous version said something about unknown
size of a structure, the current error message is
a.cpp(4) : Error: undefined use of struct or union
/Pavel
|
December 13, 2006 Re: [8.50.1n] another bug | ||||
---|---|---|---|---|
| ||||
Posted in reply to Pavel Vozenilek | Pavel Vozenilek wrote:
>> -----------------------
>> template <class T>
>> struct addable2
>> {
>> friend T operator +( T lhs, const T& rhs ) { return lhs += rhs; }
>> };
>>
>>
>> template<class T>
>> struct addable : addable2<T>
>> {
>> };
>>
>> template <class T>
>> class point : addable< point<T> >
>> {
>> };
>>
>> int main()
>> {
>> point<int> ppp;
>> return 0;
>> }
>> ----------------------------
>>
>
> I'd checked the code against 8.50.2 beta.
>
> The previous version said something about unknown
> size of a structure, the current error message is
>
> a.cpp(4) : Error: undefined use of struct or union
That's because there's no += defined for point.
|
December 13, 2006 Re: [8.50.1n] another bug | ||||
---|---|---|---|---|
| ||||
Posted in reply to Walter Bright |
"Walter Bright" wrote
> Pavel Vozenilek wrote:
>>> -----------------------
>>> template <class T>
>>> struct addable2
>>> {
>>> friend T operator +( T lhs, const T& rhs ) { return lhs += rhs; }
>>> };
>>>
>>>
>>> template<class T>
>>> struct addable : addable2<T>
>>> {
>>> };
>>>
>>> template <class T>
>>> class point : addable< point<T> >
>>> {
>>> };
>>>
>>> int main()
>>> {
>>> point<int> ppp;
>>> return 0;
>>> }
>>> ----------------------------
>>>
>>
>> I'd checked the code against 8.50.2 beta.
>>
>> The previous version said something about unknown
>> size of a structure, the current error message is
>>
>> a.cpp(4) : Error: undefined use of struct or union
>
> That's because there's no += defined for point.
>
Hmm. The operator is not called so it may not matter
(opinion, I am no C++ lawyer).
Comeau does not complain, neither does GCC 3.4.5
and VC++ 2005 also compiles it w/o problems.
/Pavel
|
December 13, 2006 Re: [8.50.1n] another bug | ||||
---|---|---|---|---|
| ||||
Posted in reply to Pavel Vozenilek |
"Pavel Vozenilek" wrote
>
> "Walter Bright" wrote
>> Pavel Vozenilek wrote:
>>>> -----------------------
>>>> template <class T>
>>>> struct addable2
>>>> {
>>>> friend T operator +( T lhs, const T& rhs ) { return lhs += rhs; }
>>>> };
>>>>
>>>>
>>>> template<class T>
>>>> struct addable : addable2<T>
>>>> {
>>>> };
>>>>
>>>> template <class T>
>>>> class point : addable< point<T> >
>>>> {
>>>> };
>>>>
>>>> int main()
>>>> {
>>>> point<int> ppp;
>>>> return 0;
>>>> }
>>>> ----------------------------
>>>>
>>>
>>> I'd checked the code against 8.50.2 beta.
>>>
>>> The previous version said something about unknown
>>> size of a structure, the current error message is
>>>
>>> a.cpp(4) : Error: undefined use of struct or union
>>
>> That's because there's no += defined for point.
>>
>
>
> Hmm. The operator is not called so it may not matter
> (opinion, I am no C++ lawyer).
>
> Comeau does not complain, neither does GCC 3.4.5
> and VC++ 2005 also compiles it w/o problems.
>
> /Pavel
>
Borland C++ 6.4 compiles the snippet as well.
/Pavel
|
December 13, 2006 Re: [8.50.1n] another bug | ||||
---|---|---|---|---|
| ||||
Posted in reply to Pavel Vozenilek | Here's another snippet showing the problem (extracted from <boost/operators.hpp>): ---------a.cpp--------------- template <class T> struct decrementable { friend T operator--(decrementable& x, int) { decrementable_type nrv(x); --x; return nrv; } private: typedef T decrementable_type; }; int main( int , char * [] ) { decrementable<int> a; return 0; } --------------------- Comeau does compile it. /Pavel |
December 14, 2006 Re: [8.50.1n] another bug | ||||
---|---|---|---|---|
| ||||
Posted in reply to Pavel Vozenilek | Pavel Vozenilek wrote:
> Hmm. The operator is not called so it may not matter
> (opinion, I am no C++ lawyer).
>
> Comeau does not complain, neither does GCC 3.4.5
> and VC++ 2005 also compiles it w/o problems.
Could you put a syntax error in the function and see if it complains?
|
December 14, 2006 Re: [8.50.1n] another bug | ||||
---|---|---|---|---|
| ||||
Posted in reply to Walter Bright | "Walter Bright" wrote: > Pavel Vozenilek wrote: >> Hmm. The operator is not called so it may not matter >> (opinion, I am no C++ lawyer). >> >> Comeau does not complain, neither does GCC 3.4.5 >> and VC++ 2005 also compiles it w/o problems. > > Could you put a syntax error in the function and see if it complains? > With VC++ 2005 syntax error within the unused function doesn't matter. GCC 3.4.5 fails with error about the syntax, Comeau also fails with the syntax. I read somewhere that unused members can be optionally syntactically checked but not semantically. A search on newsgroups seems to confirm this: Fergus Henderson: [T]he implementation _must not_ check [unused template member] (other than syntax checking)." (post from year 1995) http://groups.google.com/group/comp.std.c++/msg/0cb95f20593b7777 /Pavel |
December 14, 2006 Re: [8.50.1n] another bug | ||||
---|---|---|---|---|
| ||||
Posted in reply to Pavel Vozenilek | Pavel Vozenilek wrote:
> I read somewhere that unused members
> can be optionally syntactically checked but not semantically.
>
>
> A search on newsgroups seems to confirm this:
>
> Fergus Henderson: [T]he implementation _must not_ check
> [unused template member] (other than
> syntax checking)." (post from year 1995)
>
> http://groups.google.com/group/comp.std.c++/msg/0cb95f20593b7777
But a friend is not a member.
|
Copyright © 1999-2021 by the D Language Foundation