This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

RE: gcc 3.0 and C++


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]