Path: utzoo!mnetor!uunet!husc6!bloom-beacon!tut.cis.ohio-state.edu!mailrus!ames!pacbell!att-ih!att-cb!clyde!watmath!watdragon!violet!gjditchfield From: gjditchfield@violet.waterloo.edu (Glen Ditchfield) Newsgroups: comp.lang.c++ Subject: possible bugs Message-ID: <6112@watdragon.waterloo.edu> Date: 30 Mar 88 21:58:38 GMT Sender: daemon@watdragon.waterloo.edu Distribution: na Lines: 74 Keywords: typedef, stream.h, pointer-to-function parameters Here's three possible bugs in C++, using cfront 1.2.1 and BSD4.3 on a Vax. (The CC command has been renamed ccc locally.) 1) Cfront silently absorbs typedefs inside classes, to the confusion of C. ---------------------------------------- class bar { public: typedef int* ip; ip i; }; ---------------------------------------- ccc typedef.cc: cc -c typedef..c "typedef.cc", line 4: syntax error "typedef.cc", line 4: warning: Missing ',' or '=' in variable declaration "typedef.cc", line 4: warning: undeclared initializer name _bar_i "typedef.cc", line 4: illegal initialization "typedef.cc", line 5: syntax error ---------------------------------------- I have no idea how typedef should interact with public/private/protected, but cc should not produce error messages. 2) Declaration of "complex" variables in the middle of code causes confusion about the scope of other variables. ---------------------------------------- #include void foo() { for (int i = 1; i <= 10; i += 1) { } filebuf fb; for (char *i = (char *)0; i != 0; i += 1) { } } ---------------------------------------- If "filebuf fb;" is commented out, the messages produced are ccc redef2.cc: "redef2.cc", line 6: error: two declarations of i Similar messages are produced if the filebuf declaration is replaced by a declaration of an integer and the #include is removed. If "filebuf fb;" is not commented out, the messages produced are ccc redef2.cc: cc -c redef2..c "redef2.cc", line 6: warning: "_au1_i" redefinition hides earlier one Again, a C error is produced. 3) This is more likely to be my misunderstanding than a bug. The syntax in the back of "The C++ Programming Language" suggests that functions can have pointer-to-function parameters, but I get (uninformative) error messages unless I use a typedef. ---------------------------------------- typedef int (*PFCCI)(char, char); // ptr to fn mapping 2 chars to int. void f( PFCCI p); void g( int (*p)(char, char) ); ---------------------------------------- ccc pmf.cc: "pmf.c", line 5: error: syntax error "pmf.cc", line 5: error: syntax error "pmf.cc", line 5: error: syntax error ---------------------------------------- Does C++ require the typedef, or have I just messed up the declaration of g? 4) Is there a better place to send complaints to than this group? The local C++ maintainer doesn't know of one. Glen Ditchfield watmath!violet!gjditchfield Dept of Computer Science, U of Waterloo (519) 885-1211 x6658 Waterloo, Ontario, Canada Office: MC 2006 I'm the compiler user your professors warned you about.