glenn@synaptx.Synaptics.Com (Glenn Gribble) (12/11/89)
I finally got my Sun C++ :-). Sun included C++ versions of all their header files, even the sunwindow ones. Yeah! :-) :-) We spent 3 days sticking 'const' in appropriate places. :-| And I found some bugs/features: :-( #1) Constants can be turned into non-constants through use of reference. This causes the compiler to emit illegal c code. See bug1.cxx/bug1..c below. #2) If a member variable is a pointer to a function, then calling the function with the POINTER() syntax generates a warning where the (*POINTER)() syntax does not. See bug2.cxx below. #3) Errors in prototypes of standard functions: There are many functions (fopen(), freopen(), popen(), ... ) that are prototyped as taking 'char *' when they really take 'const char *'. fread()/fwrite() prototyped as taking 'char*', should take 'void*'. Other errors, too. #4) I thought the static initializers for files were supposed to use the first EXTERN identifier as part of their name, not the first STATIC name. Most of my initializers look like ___sti__FILE_sccsid_. #5) To guarantee proper initialization order under C++ 1.2, I created a file called aaaafirst.cxx whose constructors always got called before the other constructors. This release of C++ alphabetizes in reverse. Is there should be some standard way to force certain things to be initialized first. (istream_withassign strikes me as somewhat of a pain.) #6) Sun did not supply a version of patch, so I wrote my own. I have never actually seen a patch program, so I just guessed about what it should do from the CC driver script. My patch requires linking with my own ctor.o file that provides space to patch in the initializer function pointers. Since my resultant executable is nearly 5 megabytes (with -g), only linking once saves considerable time. If anybody wants it, send me email. This is highly Sun-specific (I used mmap() to load the file to patch), but might be of use to other people. Is/was patch part of the standard release from AT&T? #7) Compilation of one of my files resulted in a .c file that caused /lib/cpp to dump core. Fortunately, the cpp distributed with Sun's C++ product was able to preprocess that file, so I changed CC to force cc to use /usr/CC/sun3/cpp. #8) dbx does some weird stuff, but I have only run it a few times so I have nothing concrete to report. I am much happier with this release than I was with Oregon's compiler when I tried it over a year ago. -- Glenn Gribble glenn@synaptics.com uunet!synaptx!glenn ********** bug1.cxx ********** const short a = 3; void something(); void ook(short b) { switch (b) { case a: something(); break; } } void somethingBad(const short&); void ookBad(short b) { somethingBad(a); switch (b) { case a: something(); break; } } ********** bug1..c ********** /* <<AT&T C++ Translator 2.00.02 08/25/89>> */ /* < bug1.cxx > */ < new and such deleted > extern char something__Fv (); char ook__Fs (__0b )short __0b ; { switch (__0b ){ case ((short )3): something__Fv ( ) ; break ; } } extern char somethingBad__FRCs (); static short a = 3; char ookBad__Fs (__0b )short __0b ; { somethingBad__FRCs ( (short *)(& a )) ; switch (__0b ){ case a : <<<<<<<< Ooops, now cfront emits a, not (short)3 something__Fv ( ) ; break ; } } /* the end */ ************ bug2.cxx ************ typedef void (*PFV)(); class spam { public: PFV myFunc; }; void test(const spam& R) { R.myFunc(); // warn: non-const member function ? called for const object (*R.myFunc)(); } -- Glenn Gribble glenn@synaptics.com uunet!synaptx!glenn
leech@cezanne.cs.unc.edu (Jonathan Leech) (12/11/89)
In article <480@synaptx.Synaptics.Com> glenn@synaptics.com (Glenn Gribble) writes: >And I found some bugs/features: :-( > >#1) Constants can be turned into non-constants through use of reference. > This causes the compiler to emit illegal c code. > See bug1.cxx/bug1..c below. Great. I found that one several years ago in 1.2, reported it on the net and to Bjarne, and was told it was passed on to the support folks. Things were better during release E/1.0 days, when Bjarne provided all the support needed :-( -- Jon Leech (leech@cs.unc.edu) __@/ ``I have a fair amount of faith in American free press; oppression continues to surface, but justice will always triumph as long as enough money can be supplied.'' - Reed Waller