Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Bug in C++ compiler ?

2 views
Skip to first unread message

-bat.

unread,
Mar 3, 1999, 3:00:00 AM3/3/99
to
Does anybody know why the following code does not work under cc++
on OpenStep 4.2 and if there is a workaround at all ? It works fine
on other C++ compilers. If you uncomment the line in the subclass constructor
it works fine under OpenStep. Any ideas ?

-bat.

#include <stdlib.h>
#include <iostream.h>

class super_ex {
public :
super_ex(void);
virtual ~super_ex(void);
};

class sub_ex : public super_ex {
public :
sub_ex(void);
virtual ~sub_ex(void);
};

super_ex::super_ex(void)
{
cout << "Superclass constructor\n";
}

super_ex::~super_ex(void)
{
cout << "Superclass destructor\n";
}

sub_ex::sub_ex(void)
{
// cout << "Subclass constructor\n";
}

sub_ex::~sub_ex(void)
{
cout << "Subclass destructor\n";
}

int
main(void)
{
super_ex *f = new sub_ex;
cout << "Created class\n";
delete f;
}

Dr I Stephenson

unread,
Mar 6, 1999, 3:00:00 AM3/6/99
to
In article <7bjg6d$mru$1...@pump1.york.ac.uk>, pe...@ohm.york.ac.uk (-bat.) wrote:

> Does anybody know why the following code does not work under cc++
> on OpenStep 4.2 and if there is a workaround at all ? It works fine
> on other C++ compilers. If you uncomment the line in the subclass constructor
> it works fine under OpenStep. Any ideas ?
>

This looks like the one I reported about three years ago in the 4.0 beta
release (when I ported Animo to OpenStep). If you have a subclass with an
(almost) empty contructor, then the compiler forgets to set up the virtual
function dispatch table.

It seems to work properly if you turn on optimisation!

$an

-bat.

unread,
Mar 7, 1999, 3:00:00 AM3/7/99
to
iste...@bournemouth.ac.uk (Dr I Stephenson) writes:
> This looks like the one I reported about three years ago in the 4.0 beta
> release (when I ported Animo to OpenStep). If you have a subclass with an
> (almost) empty contructor, then the compiler forgets to set up the virtual
> function dispatch table.

I'm not convinced it's entirely a compiler problem though - I have
a script called 'cc3' which does 3.3 compilation under 4.2 usingall
the old headers and libraries, *but* it still uses the 4.2 compiler
to do the actual compilation. Using cc3 the code works fine, using cc it
fails.

> It seems to work properly if you turn on optimisation! > >

This is true...

Anyway, I re-wrote the whole lot in C instead - which I shiuld probably
have done anyway, I just thought C++ was an easy way to convert a load of
Objective C so the plebs on M$ could use it. Silly idea, should have known
better really. Thanks for all the advice though...

-bat.

0 new messages