Path: utzoo!utgpu!water!watmath!clyde!att!osu-cis!tut.cis.ohio-state.edu!mailrus!nrl-cmf!ames!vsi1!daver!athsys!stergios From: stergios@athsys.uucp (Stergios Marinopoulos) Newsgroups: comp.lang.c++ Subject: Misleading comment generated by cfxx (maybe cfront too?) Summary: wild goose chase Keywords: unimportant Message-ID: <123@cyclopes.UUCP> Date: 27 Aug 88 06:11:35 GMT Reply-To: stergios@athsys.UUCP (Stergios Marinopoulos) Organization: Xpert Xports Lines: 51 I was looking through the output of cfxx, Glockenspiel's port of cfront, and was lead astray by one of the cfxx generated comments. Specifically a comment is inserted next to the beginning of a class declaration stating the classes size. Follow along and I'll point it out. --------------- // This is the example program, just a class and a global instance. class Test { public: int field1 : 1 ; int field2 : 1 ; int field3 : 1 ; int field4 : 1 ; int field5 : 26 ; } ; Test globalTest ; ---------------- /* the cfxx compiled code */ /* << cfxx :- 1.2 Sun-Wk.2d >> */ struct Test { /* sizeof Test == 6 */ IT SHOULD ONLY BE 4 int _Test_field1 :1; int _Test_field2 :1; int _Test_field3 :1; int _Test_field4 :1; int _Test_field5 :26; }; struct Test globalTest ; ------------------ # the ultimate in documentation test.s .data .comm _globalTest,4 ONLY 4 BYTES WERE ALLOCATED ------------------ If you try taking the size by sizeof(class Test) the result is correctly calculated as 4. Just thought I would point this out. Stergios Marinopoulos