[comp.lang.c++] virtual functions. No fault found.

mikem@otc.OZ (Michael Mowbray) (12/14/86)

In article <8325@watrose.UUCP>, gjditchfield@watrose.UUCP (Glen Ditchfield) writes:
> C++ seems to be generating code that cc won't accept. Am I doing something
> wrong? 
> 
>  [ .. deleted ..]
>
> void f(employee* ll)
> {
>     for (; ll; ll=ll->next)
> 	  ll->print();
> }
>
> [ .. deleted .. ]
>
> When I run it through C++, I get these error messages from cc:
> "virt.cc", line 22: illegal function
> "virt.cc", line 22: illegal function
> where line 22 is "ll->print()" in function f. (The local support people
> have set things up so that C++ files must have names ending in .cc.)
> 
> C++'s output, slightly prettified, looks like this:
> ----------------
> #line 1 "virt.cc"
> 
> /* <<cfront 05/20/86>> */
> //  ...
> 
> #line 20 "virt.cc"
> int f (_auto_ll )struct employee *_auto_ll ;
> { 
> 	for(;_auto_ll ;_auto_ll = _auto_ll -> _employee_next )
> #line 22 "virt.cc"
> 		(*(((int (*)())(*_auto_ll -> _employee__vptr ))))
> 		(*(((int (*)())(*_auto_ll -> _employee__vptr ))))( _auto_ll) ;
> };
> 

I ran this, and the C-code generated was something like:

    int    f(_auto_ll)
    struct employee *_auto_ll;
    { 
	for (; _auto_ll; _auto_ll = _auto_ll->_employee_next)
		(*(((int (*)())(*_auto_ll -> _employee__vptr ))))( _auto_ll);
    }

- which compiles fine.

I'm running release 1.1 on Pyramid 90X. ( <<cfront 05/20/86>> ).

There must be a subtle bug in the port (?). What machine is being used?

			Mike Mowbray
			Systems Development
			Overseas Telecommunications Commission (Australia)

UUCP:   {seismo,mcvax}!otc.oz!mikem              ACSnet: mikem@otc.oz