Path: utzoo!attcan!uunet!mcvax!hp4nl!botter!star.cs.vu.nl!ceriel From: ceriel@cs.vu.nl (Ceriel Jacobs) Newsgroups: comp.os.minix Subject: Re: minix/ST cc peculiarity Message-ID: <1634@ceriel.cs.vu.nl> Date: 8 Nov 88 07:04:18 GMT References: <257@cstw01.UUCP> Reply-To: ceriel@cs.vu.nl (Ceriel Jacobs) Organization: VU Informatica, Amsterdam Lines: 37 To: meulenbr@cst.UUCP From: Ceriel Jacobs Subject: Re: minix/ST cc peculiarity Newsgroups: comp.os.minix In-Reply-To: <257@cstw01.UUCP> Organization: VU Informatica, Amsterdam Cc: Bcc: In article <257@cstw01.UUCP> you write: >Hi! > >I noticed the following problem in the minix st C compiler. >Given the following program: >#define SOMETHING -32768 >#include > >main() >{ > printf("%d\n", SOMETHING); >} > >The result is, that -1 is printed. >Thing work well for -32767. >Also defining SOMETHING as (int)(-32768L) works fine. > This is not a bug. The C reference manual(2.4.1) states: A decimal constant whose value exceeds the largest signed machine integer is taken to be long; Notice that -32768 in this context is not a constant, but a constant expression. The constant is 32768, which exceeds the largest signed machine integer. So, the constant expression -32768 is a long, and should thus be printed with %ld (or, in PC Minix 1.1, with %D). -- Ceriel Jacobs, Vrije Universiteit Amsterdam