public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* gcc 3.0 and C++
@ 2001-07-19 11:07 Bohdan Vlasyuk
  2001-07-20  2:48 ` Rob Taylor
  0 siblings, 1 reply; 4+ messages in thread
From: Bohdan Vlasyuk @ 2001-07-19 11:07 UTC (permalink / raw)
  To: gcc

I have strange feeling that it's a kind of `something wrong' with
gcc. Trying to compile my program on gcc 3.0, have this error:

language.cpp: In constructor `LangList::LangList()':
language.cpp:285: no matching function for call to `Data::Data(Data)'
data.h:13: candidates are: Data::Data(Data&)
data.h:11:                 Data::Data(char*)
data.h:10:                 Data::Data(long int)
language.cpp:285:   initializing argument 1 of `Language::Language(Data)' from 
   result of `Data::Data(char*)'

relevant lines:

				if(S_ISREG(statistics.st_mode))	{
					Language * newlang = new Language(directory->d_name);	
directory->d_name is char*

Language has only one constructor:

	Language(Data);


Data is a kind of universal malloc'ed type, that'd be used [in future
version :-)] for garbage collection. It can be constructed with:

	Data(long new_size);
	Data(char*s);
	Data();
	Data(Data& new_d);


I don't understand, why can't Language(char*) just make it
Language(Data(char*)), and why does it complain..

I'm sorry if that's not actually bug, and I admit I'm not very good in
C++.

P.s.: I could send actual preprocessed output, but I guess it'll wait
until anyone would actually confirm it's bug.

thanks!

-- 
You love peace.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* RE: gcc 3.0 and C++
  2001-07-19 11:07 gcc 3.0 and C++ Bohdan Vlasyuk
@ 2001-07-20  2:48 ` Rob Taylor
  2001-07-20  3:34   ` Rob Taylor
  0 siblings, 1 reply; 4+ messages in thread
From: Rob Taylor @ 2001-07-20  2:48 UTC (permalink / raw)
  To: Bohdan Vlasyuk; +Cc: Gcc@Gcc. Gnu. Org

looks like your trying to pass a temporary into a non-const reference. thats a
BAD THING. modify the constructor of Language to take a const reference or use
pass-by-copy.

Rob

> I have strange feeling that it's a kind of `something wrong' with
> gcc. Trying to compile my program on gcc 3.0, have this error:
>
> language.cpp: In constructor `LangList::LangList()':
> language.cpp:285: no matching function for call to `Data::Data(Data)'
> data.h:13: candidates are: Data::Data(Data&)
> data.h:11:                 Data::Data(char*)
> data.h:10:                 Data::Data(long int)
> language.cpp:285:   initializing argument 1 of
> `Language::Language(Data)' from
>    result of `Data::Data(char*)'
>
> relevant lines:
>
> 				if(S_ISREG(statistics.st_mode))	{
> 					Language * newlang = new
> Language(directory->d_name);
> directory->d_name is char*
>
> Language has only one constructor:
>
> 	Language(Data);
>
>
> Data is a kind of universal malloc'ed type, that'd be used [in future
> version :-)] for garbage collection. It can be constructed with:
>
> 	Data(long new_size);
> 	Data(char*s);
> 	Data();
> 	Data(Data& new_d);
>
>
> I don't understand, why can't Language(char*) just make it
> Language(Data(char*)), and why does it complain..
>
> I'm sorry if that's not actually bug, and I admit I'm not very good in
> C++.
>
> P.s.: I could send actual preprocessed output, but I guess it'll wait
> until anyone would actually confirm it's bug.
>
> thanks!
>
> --
> You love peace.
>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* RE: gcc 3.0 and C++
  2001-07-20  2:48 ` Rob Taylor
@ 2001-07-20  3:34   ` Rob Taylor
  0 siblings, 0 replies; 4+ messages in thread
From: Rob Taylor @ 2001-07-20  3:34 UTC (permalink / raw)
  To: Rob Taylor, Bohdan Vlasyuk; +Cc: Gcc@Gcc. Gnu. Org

hmm. ah, my apologies, looks like I jumped the gun a bit there... Language's
ctor is pass-by copy... hmmm ... looking at it a bit longer, this does seem a
bit weird - why on earth would gcc be trying to create a *second* temporary Data
object????

>
> looks like your trying to pass a temporary into a non-const reference. thats a
> BAD THING. modify the constructor of Language to take a const reference or use
> pass-by-copy.
>
> Rob
>
> > I have strange feeling that it's a kind of `something wrong' with
> > gcc. Trying to compile my program on gcc 3.0, have this error:
> >
> > language.cpp: In constructor `LangList::LangList()':
> > language.cpp:285: no matching function for call to `Data::Data(Data)'
> > data.h:13: candidates are: Data::Data(Data&)
> > data.h:11:                 Data::Data(char*)
> > data.h:10:                 Data::Data(long int)
> > language.cpp:285:   initializing argument 1 of
> > `Language::Language(Data)' from
> >    result of `Data::Data(char*)'
> >
> > relevant lines:
> >
> > 				if(S_ISREG(statistics.st_mode))	{
> > 					Language * newlang = new
> > Language(directory->d_name);
> > directory->d_name is char*
> >
> > Language has only one constructor:
> >
> > 	Language(Data);
> >
> >
> > Data is a kind of universal malloc'ed type, that'd be used [in future
> > version :-)] for garbage collection. It can be constructed with:
> >
> > 	Data(long new_size);
> > 	Data(char*s);
> > 	Data();
> > 	Data(Data& new_d);
> >
> >
> > I don't understand, why can't Language(char*) just make it
> > Language(Data(char*)), and why does it complain..
> >
> > I'm sorry if that's not actually bug, and I admit I'm not very good in
> > C++.
> >
> > P.s.: I could send actual preprocessed output, but I guess it'll wait
> > until anyone would actually confirm it's bug.
> >
> > thanks!
> >
> > --
> > You love peace.
> >
>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: gcc 3.0 and C++
@ 2001-07-20  4:06 Bohdan Vlasyuk
  0 siblings, 0 replies; 4+ messages in thread
From: Bohdan Vlasyuk @ 2001-07-20  4:06 UTC (permalink / raw)
  To: gcc

On Fri, Jul 20, 2001 at 11:59:05AM +0100, Rob Taylor wrote:

>>> Trying to compile my program on gcc 3.0, have this error:

>>> language.cpp:285: no matching function for call to `Data::Data(Data)'
>>> data.h:13: candidates are: Data::Data(Data&)

>> looks like your trying to pass a temporary into a non-const
>> reference. thats a BAD THING. modify the constructor of
>> Language to take a const reference or use pass-by-copy.
I've changed Data instead - made all Data constructors to take
const as parameter. It works [tends to]. But I can't do any
real development with gcc 3.0, it's too slow, unfortunately.

> hmm. looks like <hurried a bit>. Language's ctor is pass-by
> copy... hmmm ... looking at it a bit longer, this does seem a
> bit weird - why on earth would gcc be trying to create a
> *second* temporary Data object????
It confused me too, and that's the reason why I've posted it
here instead of looking for workarounds.

So, can anyone say for sure that it IS a bug, or can we just
forget it since it works??


-- 
The goal of Computer Science is to build something that will last at
least until we've finished building it.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2001-07-20  4:06 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-07-19 11:07 gcc 3.0 and C++ Bohdan Vlasyuk
2001-07-20  2:48 ` Rob Taylor
2001-07-20  3:34   ` Rob Taylor
2001-07-20  4:06 Bohdan Vlasyuk

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).