[comp.lang.c++] cfront 2.0 bug

jjc@jclark.UUCP (James Clark) (10/11/89)

cfront 2.0 (on a Sun 4) generates incorrect (but legal) C code for the
following:

inline int and(int x, int y)
{
  if (x) {
    if (y)
      return 1;
  }
  return 0;
}

extern "C" int abort(...);

main()
{
  int m = 1, n = 1;
  if (!and(m, n))
    abort();
}

Is there anybody at AT&T who is interested in receiving bug reports?
I have a couple more (not as bad as this one). Is anybody keeping a
list of cfront 2.0 bugs that aren't covered in the release notes?

James Clark
jjc@jclark.uucp

neath@solar-1.stars.flab.Fujitsu.JUNET (10/30/89)

The following code does not compile under <<AT&T C++ Translator 2.0 06/30/89>>.
However, if you comment out the line indicated,  no  problem! Is  this a bug in
the translator or a feature of the language?

	class foo {
	public:
	  foo () {}; // Comment out this line and it works!
	  foo (const char *const &) {};
	};

	void bar () {
	  char* str = "abc";
	  foo a(); 
	  foo b("abc");
	}

	CC2 -c const_bug.C
	"const_bug.C", line 10: error: bad argument list for foo::foo() 
	(no match against any  foo::foo())
	1 error

Regards
Martin Neath <neath@dsg.ti.com>
------------------------------------------------------------------------
 DISCLAIMER: As always, the opinions expressed above are strictly my own
 and do not reflect those of my employer, Texas Instruments.
------------------------------------------------------------------------

schmidt@indetech.com (Douglas C. Schmidt) (09/05/90)

Howdy,

	The following twisted program seems to trip a bug in cfront 2.0.  Does
anyone know if this is fixed in 2.1?

	thanks,
	
		Doug

----------------------------------------
extern int foo (void);

int a = 100;
int i = 10 + foo ();
int j = i + *new int (1);

foo ()
{
	static int k = foo ();
	return 100 + a;
}
----------------------------------------

	Here's the result of compiling with CC:

	% CC t.c
	"t.c", line 5: k undefined

	And here's the mangled cfront code:

----------------------------------------
CC -F t.c
#line 1 "t.c"

/* <<AT&T C++ Translator 2.0 06/30/89>> */
/* < t.c > */

#line 1 "t.c"
char *__vec_new ();

#line 1 "t.c"
char __vec_delete ();
typedef int (*__vptp)();
struct __mptr {short d; short i; __vptp f; };

#line 1 "t.c"

#line 3 "t.c"
int a = 100 ;

#line 1 "t.c"
extern int foo__Fv ();

#line 4 "t.c"
int i = 0 ;
int j = 0 ;

#line 1 "t.c"
int foo__Fv ()
#line 8 "t.c"
{ 
#line 9 "t.c"
static int __1k ;

#line 10 "t.c"
static int __0__F2 ;

#line 9 "t.c"
__0__F2 ?0 :( (__1k = foo__Fv ( ) ), (__0__F2 = 1)) ;
return (100 + a );
}

#line 1 "t.c"
extern char *__nw__FUi ();

#line 13 "t.c"
char __sti__t_c_a_ ()
#line 4 "t.c"
{ 
#line 4 "t.c"
int *__0__N1 ;
i = (10 + foo__Fv ( ) );

#line 5 "t.c"
j = (i + ((*( ( (__0__N1 = (((int *)__nw__FUi ( sizeof (int )) ))), (((*__0__N1 ))= k )) ,
#line 5 "t.c"
__0__N1 ) )));
}

#line 13 "t.c"

/* the end */
----------------------------------------
-- 
____*_  Douglas C. Schmidt          schmidt@indetech.com
\  / /  Independence Technologies   {sun,sharkey,pacbell}!indetech!schmidt
 \/ /   42705 Lawrence Place        FAX: 415 438-2034
  \/    Fremont, CA 94538           Voice: 415 438-2023