[comp.lang.c++] Member function bug II

cpf@batcomputer.tn.cornell.edu (Courtenay Footman) (10/23/87)

Much more remarkable that the fact that the previous program does not compile
is the fact that the following program does compile:
-------------------------------------------------------------------------------
struct x_s {
    int type[2];
    int s(int i)	{ return type[i]; }
};


void g(x_s *x)
{
    int *thing =  & x[1].s(1); 
}
-------------------------------------------------------------------------------
CC  bug3.c:
cc  -c  bug3..c

With no errors.

CC -Fc bug3.c gives the following.  (I have deleted #line statements and blank
lines.)

/* <<cfront 1.2.1 2/16/87>> */
/* < bug3.c */
char *_new(); char _delete(); char *_vec_new(); char _vec_delete();

struct s_s {	/* sizeof s_s == 2 */

short _s_s_s ;
};

struct x_s {	/* sizeof x_s == 8 */
int _x_s_type [2];
};

char g (_au0_x )struct x_s *_au0_x ;
{ 
int *_au1_thing ;
_au1_thing = (( & ((& (_au0_x [1 ]))-> _x_s_type [1 ])) );
}
;

/* the end */

Not only did it compile, but it even gave what the idiot who wrote
the program wanted.  (The idiot will remain nameless, if you do
not read my .signature.)  Or is this what people mean when they
talk about an "undocumented feature"? 
-- 
--------------------------------------------------------------------------------
Courtenay Footman		ARPA:	cpf@lnssun9.tn.cornell.edu
Lab. of Nuclear Studies		Usenet:	Sometimes works
Cornell University		Bitnet: cpf@CRNLNUC.BITNET