Path: utzoo!attcan!uunet!husc6!cs.utexas.edu!pp!riunite!rfg From: rfg@riunite.ACA.MCC.COM (Ron Guilmette) Newsgroups: comp.lang.c++ Subject: Uses of incomplete types... which ones are legal? Message-ID: <90@riunite.ACA.MCC.COM> Date: 22 Jan 89 18:32:27 GMT Reply-To: rfg@riunite.UUCP (Ron Guilmette) Organization: MCC Austin, Texas Lines: 61 I am reposting the following response from ekrell to my question about an apparent bug in GNU G++ with incomplete types. Some people may be interested in seeing how AT&T cfront 2.0 responds. ------------------------------------------------------------------------ >From ekrell%ulysses@research.att.com Sat Jan 21 13:06:09 1989 This is AT&T cfront 2.0: x.C: 1 class first_class; 2 3 class second_class { 4 public: 5 first_class some_function (); 6 }; 7 8 another_function () 9 { 10 second_class second_class_object; 11 12 second_class_object.some_function (); 13 } nCC -c x.C: "x.C", line 12: error: first_class undefined, size not known "x.C", line 10: warning: second_class_object used but not set ------------------------------------------------------------------------ Since G++ issues *no* errors for the code above, it seems apparent that there is at least one bug in G++ (1.32.0) regarding incomplete types. I have also noted that G++ issues no errors even if the incomplete type name (first_class) is used as a formal parameter type in the declaration of "some_function". Note that the above example is similar to one on page 290 of "The Book". The example there shows why one would like to be able to use the names of "incomplete" types in the specification of the parameter and return types for a function. Unfortunately, the usage shown seems to conflict with my understanding of the rules regarding allowed uses of incomplete type in ANSI C, i.e. that these type names can only be used to declare pointer types & objects. I don't see anywhere in The Book where the allowed deviations from this simple ANSI rule are explicitly stated. Did I miss something in The Book, or did I miss something in the ANSI C draft? Please... I don't mind reading TFM, but just point me to where to look. (The index in The Book doesn't help much. I looked for "incomplete types" and it isn't even in there). // Ron Guilmette - MCC - Experimental (parallel) Systems Kit Project // 3500 West Balcones Center Drive, Austin, TX 78759 - (512)338-3740 // ARPA: rfg@mcc.com // UUCP: {ihnp4,seismo,ucb-vax,gatech}!cs.utexas.edu!pp!rfg -- // Ron Guilmette - MCC - Experimental (parallel) Systems Kit Project // 3500 West Balcones Center Drive, Austin, TX 78759 - (512)338-3740 // ARPA: rfg@mcc.com // UUCP: {ihnp4,seismo,ucb-vax,gatech}!cs.utexas.edu!pp!rfg