pelle@eva.slu.se (OVE EWERLID) (04/26/89)
If this has been reported before, please ignore! G++ 1.35-, running on a sun3; Consider: -+- -+- -+- class Test { protected: double xx, yy, zz; public: Test(doubel, double, double); } // Semicolon missing! dummy(){} // This seems to replace the missing semicolon after the class! inline Test::Test(double x, doubel y, double z) { xx=x; yy=y; zz=z; } main(){} -+- -+- -+- // The above compiles, but should it? // I think the answer is no as the above is invalid C++! // Now look at the this: -+- -+- -+- class Test { protected: double xx, yy, zz; public: Test(doubel, double, double); }; // The semicolon added inline Test::Test(double x, doubel y, double z) { xx=x; yy=y; zz=z; } -+- -+- -+- // which is the valid C++ code. // The bug seems to be the fact that one can leave out the semicolon // after a class definition and replace it with a dummy function. // I haven't checked, but it may also apply to structs.
tiemann@YAHI.STANFORD.EDU (Michael Tiemann) (04/26/89)
class Test { protected: double xx, yy, zz; public: Test(doubel, double, double); } // Semicolon missing! dummy(){} // This seems to replace the missing semicolon after the class! inline Test::Test(double x, doubel y, double z) { xx=x; yy=y; zz=z; } You get what you deserve when you say dummy(){} instead of int dummy(){} If you specify the return type, the compiler will issue an error message. Otherwise it needs infinite lookahead to determine whether or not you made an erroneous declaration. Michael