C compiler bug (I think).

Krzysztof Kozminski kris at ur-valhalla.UUCP
Sat Aug 25 06:54:47 AEST 1984


Apparenly, cc compiler does not tolerate shifting unsigned values in
initialization of global variables. Trying to compile the subroutine on
the left produces the diagnostics:

    line 1: compiler error: expression causes compiler loop: try simplifying

These are source files:
	       bad.c                               good.c
 +-------------------------------------+---------------------------------------+
 | int one = (((unsigned) 2) >> 1);    |    int ONE()                          |
 | int ONE()                           |    {                                  |
 | {                                   |    int one = (((unsigned) 2) >> 1);   |
 | return one;                         |    return one;                        |
 | }                                   |    }                                  |
 +-------------------------------------+---------------------------------------+

However, after moving the declaration inside the subroutine as in the
subroutine on the right, everything works OK.

Unless I missed something, The Book does not forbid what I tried to do
(actually, I tried to initialize something to a largest positive
signed integer, i.e., complemented, unsigned zero shifted right by 1. After
I got a similar error message, a couple of experiments determined a minimum
expression causing the error).

Lint also complains about the initialization:
   bad.c(1): illegal initialization

Same thing happens when initializing static variables local to a procedure.
Does anybody have an explanation/fix for this error message ?
We run 4.1c BSD in case this matters (but the same thing occurs in 4.2).
-- 
	Krzysztof Kozminski
	{seismo,allegra,decvax}!rochester!ur-valhalla!kris



More information about the Comp.lang.c mailing list