[comp.lang.c++] Misleading comment generated by cfxx

stergios@athsys.uucp (Stergios Marinopoulos) (08/27/88)

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