Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.2 7/17/84; site ur-valhalla.UUCP Path: utzoo!linus!decvax!decwrl!sun!qubix!ios!apple!voder!nsc!hplabs!hao!seismo!rochester!ur-valhalla!kris From: kris@ur-valhalla.UUCP (Krzysztof Kozminski) Newsgroups: net.lang.c Subject: C compiler bug (I think). Message-ID: <73@ur-valhalla.UUCP> Date: Fri, 24-Aug-84 16:54:47 EDT Article-I.D.: ur-valha.73 Posted: Fri Aug 24 16:54:47 1984 Date-Received: Thu, 30-Aug-84 19:08:43 EDT Distribution: net Organization: U. of Rochester, EE Dept. Lines: 34 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