Possible bug with initialization.

Chittaranjan Mandal chitta@cse.iitkgp.ernet.in
Fri Aug 25 23:37:00 GMT 2000


The initialization of aexp3 shown below does not work.
---------------------------------------------------------------------
expTreeTyp	aexp1 = { valNode , { 1 } };
expTreeTyp	aexp2 = { valNode , { 2 } };
expTreeTyp	aexp3 = { oprNode , { { IADD , & aexp1 , & aexp2 } } };
---------------------------------------------------------------------

The entire program is attaced as aet.c
The output of "cc -v aet.c" is attached next.

The correct evaluation of aexp3 should have been 3.
The output of the program is as follows:
---------------------------------------------------------------------
[chitta@csehcl56 test]$ ./a.out 
The value of aexp1 is: 1
The value of aexp2 is: 2
The value of aexp3 is: 1073955171
---------------------------------------------------------------------

The type definition of expTreeTyp is shown below.

typedef enum {
	IDIV, IMUL, IADD, ISUB
} iopsTyp;

typedef enum {
	valNode, oprNode
} expTNodeFlag;

typedef struct expTreeStu {
expTNodeFlag			flag;
union {
	int			ival;
	struct {
	  iopsTyp		opr;
	  struct expTreeStu	*lChild, *rChild;
	} opNod;
} aetNode;
} expTreeTyp, *expTreePtr;
----------------------------------------------------------------------

Your initial comments on this possible bugs would be very much
appreciated.


Best regards,            Dial-in: 77393 `*' <extn.> or 8 <extn.>
Chitta                   Tel: +91 3222 <dial-in> Extn: (off) 3498, (res) 3499
Dept. of CSE, IIT, Kgp.  Fax: +1 801 5159121, +44 870 2842932, +91 3222 55303


More information about the Gcc-bugs mailing list