[comp.sys.mips] Bug in 'cc'

robertl@cwi.nl (Robert van Liere) (02/12/91)

I'm not sure if this is the right newsgroup but
the following program displays a (maybe well-known) bug 
in the MIPS C compiler (version 2.0). I'm running on a 
SGI 4D/25.

---------- x.c ---------------
main ()
{
    char c = 'a';
#ifdef PLUSBECOMES
    c += (double) 1.0;
#else
    c = c + (double) 1.0;
#endif
    printf ("c = %c\n", c);
}
---------- x.c ---------------


Compile as follows :

  $ cc -float -DPLUSBECOMES xx.c
  as1: Warning: xx.c, line 5: nop must be inside .set noreorder section
  $ a.out
  $ c = a
  $ cc -float xx.c
  $ a.out
  $ c = b

Additional comments :

  * Compiling without the '-float' flag gives the same (and correct)
    result in both cases.

  * Compiling without an explicit cast in the assignment statements  
    gives the same (and correct) result in both cases.



-- Robert van Liere


---------------------------------
Robert van Liere, Department of Interactive Systems,
Center for Mathematics and Computer Science (CWI)
Kruislaan 413,  1098 SJ  Amsterdam,  The Netherlands
robertl@cwi.nl
-- 
Robert van Liere, Department of Interactive Systems,
Center for Mathematics and Computer Science (CWI)
Kruislaan 413,  1098 SJ  Amsterdam,  The Netherlands
robertl@cwi.nl