ahvermen@watcgl.waterloo.edu (Al Vermeulen) (05/12/89)
In my last posting I posted some code that did not demonstrate the particular bug I'm worried about. My apologies to the net. I think that the following piece of code honestly does demonstrate the cfront bug that's bothering me: code: struct A { A::A( A& ) {} }; void func(A); void func( A ) { } cfront produces the following (incorrect) ANSI C code: # 1 "weird.c" /* <<cfront 1.2.1 2/16/87>> */ /* < weird.c */ # 1 "weird.c" char *_new(); char _delete(); char *_vec_new(); char _vec_delete(); # 1 struct A { char _dummy; }; # 5 char func (struct A ); # 7 extern char func (_au0__A2 )struct A *_au0__A2 ; { } ; /* the end */ Notice that the declaration of func (line # 5) specifies that func takes an instance of struct A, the definition of func (line #7) says func takes a pointer to a struct A. I believe that the definition (line #7) is correct, since the code compiles fine on another machine we have that does not use ANSI C. I can't change cfront to emit K&R (rather than ANSI) C because I don't have source. My current work around is to pass references to A, and make local variable copies in func(). Is this bug fixed in version 2.0? -- Al Vermeulen (al@watsup, ahvermen@watcgl) al@watsup.waterloo.edu
diamond@diamond.csl.sony.junet (Norman Diamond) (05/16/89)
In article <9671@watcgl.waterloo.edu> ahvermen@watcgl.waterloo.edu (Al Vermeulen) writes: >I think that the following piece of code honestly does demonstrate the >cfront bug that's bothering me: 1 >struct A { 2 > A::A( A& ) {} 3 >}; 4 > 5 >void func(A); 6 > 7 >void func( A ) 8 >{ 9 >} >cfront produces the following (incorrect) ANSI C code: Cfront allows the defininition on line 7? A type with no formal parameter named? ># 5 >char func (struct A ); ># 7 >extern char func (_au0__A2 )struct A *_au0__A2 ; >{ } >; >Notice that the declaration of func (line # 5) specifies that func >takes an instance of struct A, the definition of func (line #7) says >func takes a pointer to a struct A. I believe that the definition >(line #7) is correct, since the code compiles fine on another machine >we have that does not use ANSI C. What code is emitted on your other machine? Or is it a pure compiler? What is your real line 7? If your code actually defines void func (A* x) or void func (A& x) , then it really is different from line 5. -- Norman Diamond, Sony Computer Science Lab (diamond%csl.sony.co.jp@relay.cs.net) The above opinions are my own. | Why are programmers criticized for If they're also your opinions, | re-implementing the wheel, when car you're infringing my copyright. | manufacturers are praised for it?