Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!linus!decvax!decwrl!pyramid!ut-sally!seismo!umcp-cs!chris From: chris@umcp-cs.UUCP (Chris Torek) Newsgroups: net.lang.c Subject: Re: A diagnostic "gotcha" Message-ID: <3181@umcp-cs.UUCP> Date: Wed, 12-Feb-86 17:30:34 EST Article-I.D.: umcp-cs.3181 Posted: Wed Feb 12 17:30:34 1986 Date-Received: Fri, 14-Feb-86 05:44:00 EST References: <648@tymix.UUCP> <659@tymix.UUCP> Organization: U of Maryland, Computer Science Dept., College Park, MD Lines: 27 In article <659@tymix.UUCP> kanner@tymix.UUCP (Herb Kanner) writes: >A line of C code that looked like: > > node_mem[*dotp] = val & 0xff; > >produced the diagonistic "operands of + have incompatible types." The >error was that *dotp was not of type int, and a[b] being a euphemism for >*(a + b), it complained about the operands of addition. At a guess, I would say that `dotp' was declared as a pointer to an enumerated type. `char' and `short' are promoted to `int' in addition expressions. `enum's being what they are (half in and half out of integer space at the moment), the 4.2 and 4.3 BSD C compilers will not allow them to be added to pointers. The ANSI standard should clear this up. In the meantime, a cast suffices to make the compiler accept the code: node_mem[(int) *dotp] = val & 0xff; ---though to my mind using enumerated types as indicies is `treading on thin ice' (I have no explanation as to why I feel this way; I just do). -- In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 1415) UUCP: seismo!umcp-cs!chris CSNet: chris@umcp-cs ARPA: chris@mimsy.umd.edu