west@calgary.UUCP (Darrin West) (04/14/88)
We have at&t c++ v1.1 I have a bit of a vague bug. This is due mainly to the size of the program in which the bug is exhibiting itself (I have spent many hours chopping out hunks of code in order to narrow down the bug, with little success). Perhaps someone else has run across it already, and will recognise it. I recently added a class v_time to a simulation library I have been working on. It has a few contstructors, an operator int and an assignment operator. This addition causes a later call of a function to create bad c code. (I know this because removing the v_time declaration reverses the problem) The function is much like a printf or exec call, where the last eight parameters are char *'s, and have default initializers of NULL. Without the v_time code, a call of the function compiles properly, initializing the last few arguments to zero. With the code, c++ beleives the arguments should be converted to type v_time, and generates c code to call the v_time operator int. It just happens that that code also takes the address of the constant 0, and thus does not go through the c compiler. When the function is not declared to have default initializers the problem also does not occur. Has anyone seen this happen before? Any suggestions will be much appreciated (bug fixes will elicit large amounts of praise and gratitude). The following code (and a bunch more besides) generates the c code that follows the /***********/ class v_time{ int t; double dummy; public: v_time(){t=0;} v_time(int i){t=i;} operator int();//{return(t);} // this doesn't want to compile inline int operator= (int i) { return(t = i);} }; pid _create_req(char *type,char *group,char *name,char *a, char *b,char *c,char *d,char *e,char *f,char *g,char *h); pid new_st(char *group,char *name,char *a=0,char *b=0,char *c=0, char *d=0,char *e=0,char *f=0,char *g=0,char *h=0) { return(_create_req("st",group,name,a,b,c,d,e,f,g,h)); } /**************/ _auto_s = ( new_st ( & _auto__R7 , "m3", "st", _v_time__OI ( (struct v_time *)(& 0 )) , _v_time__OI ( (struct v_time *)(& 0 )) , _v_time__OI ( (struct v_time *)(& 0 )) , _v_time__OI ( (struct v_time *)(& 0 )) , _v_time__OI ( (struct v_time *)(& 0 )) , _v_time__OI ( (struct v_time *)(& 0 )) , _v_time__OI ( (struct v_time *)(& 0 )) , _v_time__OI ( (struct v_time *)(& 0 )) ) , _auto__R7 ) ; Does this bug remain in v1.2? What is the most recent version? -- Darrin West, Newly MSc. ..![ubc-vision,ihnp4]! Jade@Department of Computer Science alberta!calgary!west University of Calgary. west@calgary.cdn Brain fault (cortex dumped)