This is the mail archive of the gcc-bugs@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]
Other format: [Raw text]

c++/8678: c++


>Number:         8678
>Category:       c++
>Synopsis:       c++
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          rejects-legal
>Submitter-Id:   net
>Arrival-Date:   Fri Nov 22 08:16:00 PST 2002
>Closed-Date:
>Last-Modified:
>Originator:     
>Release:        3.1.1
>Organization:
>Environment:
System: SunOS saturn 5.8 Generic_108528-16 sun4u sparc SUNW,Sun-Fire-880
Architecture: sun4

	
host: sparc-sun-solaris2.8
build: sparc-sun-solaris2.8
target: sparc-sun-solaris2.8
configured with: ../gcc-3.1.1/configure --host=sparc-sun-solaris2.8 --prefix=/opt/local --with-local-prefix=/opt/local --enable-shared --enable-threads --disable-nls --with-cpu=supersparc --enable-libgcj
>Description:
	The compiler doesn't accept nested constructor calls, if the inner variable is constructed at this place with a nonconstant parameter.
	But it works, if this parameter ist casted to the type it already has...
>How-To-Repeat:


	class A {
		public:
			A(const char *str) { }
	};

	class B {
		public:
			B(const A& a) { }
			int fkt(void) {return 0;}
	};

	int main(int argc, char *argv[]) {
		char *str = "foo";
		B b(A(argv[1]));	//should be a variable definiton - interpreted as declaration?
		B b2(A("test"));	
		B b3(A(str));		//as above - interpreted as declaration?
		B b4(A((char *) str));  //why does this work?!

		b.fkt();	//error - why?
		b2.fkt();
		b3.fkt();	//error - why?
		b4.fkt();

		return 0;
	};
	
	
	/*error output:
		main.cc: In function `int main(int, char**)':
		main.cc:18: request for member `fkt' in `b(A*)', which is of non-aggregate type 
   		`B ()(A*)'
		main.cc:20: request for member `fkt' in `b3(A)', which is of non-aggregate type 
   		`B ()(A)'
   	*/
		

>Fix:
	Casting the parameter to the type it already has works sometimes.
	Creating an A before calling the B-constructor and using it as parameter (  A a(argv[1]); b B(A);  ) should work, too.

>Release-Note:
>Audit-Trail:
>Unformatted:


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