[comp.lang.c++] cfront bug

skinner@saturn.ucsc.edu (Robert Skinner) (06/04/89)

I have seen cfront die horribly (sometimes not even dumping core)
when it encounters control characters in its input.  Will 2.0
at least be able to handle this more gracefully, and give an
error message before it commits suicide?

(No, I don't intentionally put control characters in my source
code.  This happened to me the first time when a bug in job control
put a stray character in my source.  vi didn't display the offending
character, and if it wasn't for 'cat -v', I might >still< be 
trying to find the problem.)

Robert Skinner
skinner@saturn.ucsc.edu

glenn@synaptx.Synaptics.Com (Glenn Gribble) (07/06/90)

System: Sun 3/280, Sun C++, /* <<AT&T C++ Translator 2.00.02 08/25/89>> */

The following bit of C++ generates illegal C code:

  int x;
  int y = x = 0;

Generates the following C code:

  int x = 0 ;
  int y = (x = 0 );

Ooops.

-- 
Glenn Gribble	 	glenn@synaptics.com 	uunet!synaptx!glenn

ark@alice.UUCP (Andrew Koenig) (07/06/90)

In article <1022@synaptx.Synaptics.Com>, glenn@synaptx.Synaptics.Com (Glenn Gribble) writes:
> System: Sun 3/280, Sun C++, /* <<AT&T C++ Translator 2.00.02 08/25/89>> */

> The following bit of C++ generates illegal C code:

>   int x;
>   int y = x = 0;

> Generates the following C code:

>   int x = 0 ;
>   int y = (x = 0 );

Fixed in 2.1.
-- 
				--Andrew Koenig
				  ark@europa.att.com

glenn@synaptx.Synaptics.Com (Glenn Gribble) (07/07/90)

In article <1022@synaptx.Synaptics.Com> I wrote:
>The following bit of C++ generates illegal C code:
>
>  int x;
>  int y = x = 0;

In this example, it is not clear that these are *GLOBAL* variables.

Here is another example that is totally clear and shows another part
of the same problem.

The two problems here:
  1) Cfront generated illegal C code.
  2) Cfront reports a warning in the local-variable case, but not in the
     global variable case--it should have also warned:
       "bug.cxx", line 5: warning: a used before set

synaptx% cat -n bug.cxx
   1  extern int f(int);
   2  extern int x;
   3  int y = (x = f(x));
   4
   5  int a = (x = f(a));
   6
   7  void foo()
   8  {
   9    int b = (x = f(b));
  10  }
synaptx% CC -c +i bug.cxx
CC  bug.cxx:
"bug.cxx", line 9: warning:  b used before set
cc  -Qpath /usr/CC/sun3   -c -I/usr/CC/incl  bug.c
"bug.c", line 16: illegal initialization
"bug.c", line 16: cannot recover from earlier errors: goodbye!
synaptx% cat -n /tmp/bug..c
   1
   2  /* <<AT&T C++ Translator 2.00.02 08/25/89>> */
   3  /* < bug.cxx > */
   4
   5  char *__vec_new ();
   6
   7  char __vec_delete ();
   8  typedef int (*__vptp)();
   9  struct __mptr {short d; short i; __vptp f; };
  10
  11
  12  extern int x ;
  13
  14  extern int f__Fi ();
  15
  16  int y = (x = f__Fi ( x ) );
  17
  18  int a = (x = f__Fi ( a ) );
  19
  20  char foo__Fv ()
  21  {
  22  int __1b ;
  23
  24  __1b = (x = f__Fi ( __1b ) );
  25
  26  }
  27
  28
  29  /* the end */
-- 
Glenn Gribble	 	glenn@synaptics.com 	uunet!synaptx!glenn