Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > gcc 3.3.1 compiling - object required

Reply
Thread Tools

gcc 3.3.1 compiling - object required

 
 
ken
Guest
Posts: n/a
 
      07-22-2003

IN the new gcc 3.3.1 I am getting messages like these:

/data2/office/tools/bootstrp/sstring.cxx:105: error: cannot call
member function `ULONG Container::Count() const' without object

Where the Count is defined like this in the class:

using Container::Count;

So far I have worked around this by creating a member function. The
latest one was a bit above me but I ended up changing the code from:

< delete static_cast< INetContentTypeParameter * >(Remove(Count() - 1));
---
> delete static_cast< INetContentTypeParameter * >(this->Remove(Count()

- 1));

This just does not make sense to me, surely the compiler should work out
that this is there. In full:

void INetContentTypeParameterList::Clear()
{
while (Count() > 0)
delete static_cast< INetContentTypeParameter * >(this->Remove(Count() - 1));
}

Is this a compiler bug or a stronger enforcement of some standard?

KenF


 
Reply With Quote
 
 
 
 
Victor Bazarov
Guest
Posts: n/a
 
      07-22-2003
"ken" <> wrote...
>
> IN the new gcc 3.3.1 I am getting messages like these:
>
> /data2/office/tools/bootstrp/sstring.cxx:105: error: cannot call
> member function `ULONG Container::Count() const' without object
>
> Where the Count is defined like this in the class:
>
> using Container::Count;


In which class? Does it inherit from 'Container'?

> So far I have worked around this by creating a member function. The
> latest one was a bit above me but I ended up changing the code from:
>
> < delete static_cast< INetContentTypeParameter * >(Remove(Count() - 1));
> ---
> > delete static_cast< INetContentTypeParameter * >(this->Remove(Count()

> - 1));


Whose member function is "Remove"?

>
> This just does not make sense to me, surely the compiler should work out
> that this is there. In full:
>
> void INetContentTypeParameterList::Clear()
> {
> while (Count() > 0)
> delete static_cast< INetContentTypeParameter * >(this->Remove(Count() -

1));
> }
>
> Is this a compiler bug or a stronger enforcement of some standard?


Post more code. Preferably, in compilable form.

Victor


 
Reply With Quote
 
 
 
 
ken
Guest
Posts: n/a
 
      07-23-2003


OK now I can actually see something that might be the problem, the class I
am using is derived from List

class List : private Container
{
public:
using Container::Insert;
using Container::Replace;
using Container::Clear;
using Container::GetCurObject;
using Container::GetCurPos;
using Container::GetObject;
using Container::GetPos;
using Container::Seek;
using Container::First;
using Container::Last;
using Container::Next;
using Container:rev;
using Container::Remove;

So the Remove is declare private by inheritance above but the using
statement is supposed to override the private to public. I added the
"using" clause at someones suggestion but it did not make any difference,
with or without the using clause.

The actual class where it is trying to be used we are seeing:

class INetContentTypeParameterList: private List

So if it is using inheritance then it should fail, but the using clause
should make that specific routine public. Is this right or wrong?

Thanks
KenF
 
Reply With Quote
 
ken
Guest
Posts: n/a
 
      07-23-2003
On Wed, 23 Jul 2003 09:33:24 -0400, Victor Bazarov wrote:

> "ken" <> wrote...
>>
>>
>> OK now I can actually see something that might be the problem, the class I
>> am using is derived from List
>>
>> class List : private Container
>> {
>> public:
>> using Container::Insert;
>> using Container::Replace;
>> using Container::Clear;
>> using Container::GetCurObject;
>> using Container::GetCurPos;
>> using Container::GetObject;
>> using Container::GetPos;
>> using Container::Seek;
>> using Container::First;
>> using Container::Last;
>> using Container::Next;
>> using Container:rev;
>> using Container::Remove;
>>
>> So the Remove is declare private by inheritance above but the using
>> statement is supposed to override the private to public.

>
> Correct. It creates aliases for the names in 'using' declarations.
> Those aliases are in 'public' area, so they are public for 'List'.
>
>> I added the
>> "using" clause at someones suggestion but it did not make any difference,
>> with or without the using clause.

>
> It depends on what difference you thought it would make.
>
>>
>> The actual class where it is trying to be used we are seeing:
>>
>> class INetContentTypeParameterList: private List
>>
>> So if it is using inheritance then it should fail, but the using clause
>> should make that specific routine public. Is this right or wrong?

>
> Is what right or wront? 'List' is a private base class of 'INet...List'.
> All its members, including the aliases you added to 'List' with 'using'
> declarations, are private to the outside of 'INet...List'. However,
> they should be visible (accessible) in the members of 'INet...List' class.
>
> Example:
>
> class Bottom {
> public:
> void foo();
> protected:
> void bar();
> };
>
> class Middle : private Bottom {
> public:
> using Bottom::bar(); // 'Middle::bar' is public
> };
>
> class Top : private Middle {
> void member();
> };
>
> void Top::member() {
> bar(); // this is OK -- Middle::bar is accessible here
> }
>
> int main() {
> Top top;
> top.bar(); // error -- anything from Middle is private
> // if accessed through Top object
>
> Middle middle;
> middle.bar(); // OK -- Middle::bar is public
> }
>
> Victor


So going back to my original code:

void INetContentTypeParameterList::Clear()
{
while (Count() > 0)
delete static_cast< INetContentTypeParameter * >(this->Remove(Count() - 1));
}


The Remove call is public from list which is in turn inherited as private
intoINetContentTypeParameterList so any routine within
INetContentTypeParameterList should be able to use Remove without any conflict.

So in this case should the compiler find the inheritance of Remove from
list and not need the explicit "this->" pointer? If I remove "this->" the
compiler is giving:

/data2/office/tools/source/fsys/dirent.cxx:347: error: cannot call member
function `??? Container::Remove()' without object

Is this a bug with gcc 3.3.1 or something else?

Ta
KenF

PS: Does anyone have a web link on the using clause searching for a
common word such as using does not work very well.
 
Reply With Quote
 
Victor Bazarov
Guest
Posts: n/a
 
      07-23-2003
"ken" <> wrote...
> On Wed, 23 Jul 2003 09:33:24 -0400, Victor Bazarov wrote:
>
> > "ken" <> wrote...
> >>
> >>
> >> OK now I can actually see something that might be the problem, the

class I
> >> am using is derived from List
> >>
> >> class List : private Container
> >> {
> >> public:
> >> using Container::Insert;
> >> using Container::Replace;
> >> using Container::Clear;
> >> using Container::GetCurObject;
> >> using Container::GetCurPos;
> >> using Container::GetObject;
> >> using Container::GetPos;
> >> using Container::Seek;
> >> using Container::First;
> >> using Container::Last;
> >> using Container::Next;
> >> using Container:rev;
> >> using Container::Remove;
> >>
> >> So the Remove is declare private by inheritance above but the using
> >> statement is supposed to override the private to public.

> >
> > Correct. It creates aliases for the names in 'using' declarations.
> > Those aliases are in 'public' area, so they are public for 'List'.
> >
> >> I added the
> >> "using" clause at someones suggestion but it did not make any

difference,
> >> with or without the using clause.

> >
> > It depends on what difference you thought it would make.
> >
> >>
> >> The actual class where it is trying to be used we are seeing:
> >>
> >> class INetContentTypeParameterList: private List
> >>
> >> So if it is using inheritance then it should fail, but the using

clause
> >> should make that specific routine public. Is this right or wrong?

> >
> > Is what right or wront? 'List' is a private base class of

'INet...List'.
> > All its members, including the aliases you added to 'List' with 'using'
> > declarations, are private to the outside of 'INet...List'. However,
> > they should be visible (accessible) in the members of 'INet...List'

class.
> >
> > Example:
> >
> > class Bottom {
> > public:
> > void foo();
> > protected:
> > void bar();
> > };
> >
> > class Middle : private Bottom {
> > public:
> > using Bottom::bar(); // 'Middle::bar' is public
> > };
> >
> > class Top : private Middle {
> > void member();
> > };
> >
> > void Top::member() {
> > bar(); // this is OK -- Middle::bar is accessible here
> > }
> >
> > int main() {
> > Top top;
> > top.bar(); // error -- anything from Middle is private
> > // if accessed through Top object
> >
> > Middle middle;
> > middle.bar(); // OK -- Middle::bar is public
> > }
> >
> > Victor

>
> So going back to my original code:
>
> void INetContentTypeParameterList::Clear()
> {
> while (Count() > 0)
> delete static_cast< INetContentTypeParameter * >(this->Remove(Count() -

1));
> }
>
>
> The Remove call is public from list which is in turn inherited as private
> intoINetContentTypeParameterList so any routine within
> INetContentTypeParameterList should be able to use Remove without any

conflict.
>
> So in this case should the compiler find the inheritance of Remove from
> list and not need the explicit "this->" pointer? If I remove "this->" the
> compiler is giving:
>
> /data2/office/tools/source/fsys/dirent.cxx:347: error: cannot call member
> function `??? Container::Remove()' without object
>
> Is this a bug with gcc 3.3.1 or something else?


I think it's a bug in gcc. Similar code:

class Contained {};

class Container {
public:
int Count();
void* Remove(int);
};

class List : private Container {
public:
using Container::Count;
using Container::Remove;
};

class INetContentTypeParameterList : private List {
public:
void Clear();
};

void INetContentTypeParameterList::Clear() {
while (Count())
delete static_cast<Contained*>(Remove(Count() - 1));
}

int main() {
INetContentTypeParameterList ilist;
ilist.Clear();
}

compiles fine with, for example, Comeau and even Visual C++ v6.

>
> Ta
> KenF
>
> PS: Does anyone have a web link on the using clause searching for a
> common word such as using does not work very well.


What do you mean? I searched Google for "using declaration" (yes,
in quotes), and got plenty of C++ links.

Victor


 
Reply With Quote
 
ken
Guest
Posts: n/a
 
      07-23-2003
On Wed, 23 Jul 2003 10:14:59 -0400, Victor Bazarov wrote:

> compiles fine with, for example, Comeau and even Visual C++ v6.


I have raised this as a bug with gcc. Thanks for your patience.

>> PS: Does anyone have a web link on the using clause searching for a
>> common word such as using does not work very well.

>
> What do you mean? I searched Google for "using declaration" (yes,
> in quotes), and got plenty of C++ links.


It is all in the words

KenF
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Gcc 3.4.X to Gcc 4.1.X upgrading kas C++ 1 04-22-2010 08:56 PM
GCC 3.4.3 and GCC 4.1.2 ashnin C++ 1 07-07-2008 01:10 PM
Template construction in old gcc 3.3.3 does not compile in gcc 3.4.4 eknecronzontas@yahoo.com C++ 5 09-17-2005 12:27 AM
gcc 2.95 and gcc 3.2 gouqizi.lvcha@gmail.com C++ 8 03-16-2005 02:34 AM
C99 structure initialization in gcc-2.95.3 vs gcc-3.3.1 Kevin P. Fleming C Programming 2 11-06-2003 05:15 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57