[comp.lang.c++] Solar Bugs

russb@sampson.JPL.NASA.GOV (Russ Brill) (01/30/91)

I have discovered what appear to me to be 2 bugs in the Sun 2.0 cfront.
Am I right?  Does Sun already know about these?

Bug #1:

When the following program is compiled, the compiler will issue a
warning that D::f() has hidden B::f(int) (as it should), but it will
not tell you that you must define a D::f(int), and the program will
crash!


#include <iostream.h>

class B {
public:
	virtual void f(int) = 0;
};

class D : public B {
public:
	void f() {cout << "running D::f()" << endl;}
};

main()
{
	D d;
	B* pb = &d;

	pb->f(3);
}

[end of program]


Bug #2:

When the following program is compiled, it only elicits a warning
(rather than the expected error) about calling a non-const member
function in a const object, and the program runs as if the object were
*not* const.

#include <iostream.h>

class C {
	int i;
public:
	C() {i = 0;}
	void f(int j) {i = j; cout << "new i = " << i << endl;}
};

main()
{
	const C c;
	c.f(3);
}


[end of program]