From mboxrd@z Thu Jan 1 00:00:00 1970 From: Kevin Buettner To: Eli Zaretskii Cc: gdb-patches@sourceware.cygnus.com, jeffh@redhat.com Subject: Re: [RFA] fix gdb.base/remote.c for small int targets Date: Fri, 31 Aug 2001 09:45:00 -0000 Message-id: <1010831164514.ZM23469@ocotillo.lan> References: <2110-Fri31Aug2001102556+0300-eliz@is.elta.co.il> <1010831152902.ZM23264@ocotillo.lan> <3791-Fri31Aug2001185918+0300-eliz@is.elta.co.il> X-SW-Source: 2001-08/msg00321.html On Aug 31, 6:59pm, Eli Zaretskii wrote: > > > > +#if INT_MAX < 32768 > > > > > > Shouldn't you use 32768L or 32768U? If an int is only 16 bits wide, > > > 32768 might overflow into the sign bit, and then all bets are off. > > > > Although not incorrect, using 32768L or 32768U is not necessary. > > According to section 7.11.1 of Harbison and Steele: > > What version of the C standard is this from? The book that I was quoting is the Fourth Edition of "C, a Reference Manual" by Samuel P. Harbison and Guy L. Steele Jr. Its copyright is 1995 by Prentice Hall. I've reviewed the introductory material and it claims to document ISO C. It also documents traditional (aka K&R) C, but I believe the book notes those places where traditional C differs from ISO C. Also, the book documents the 1994 (Amendment 1) extensions to the ISO C standard, but it designates these as extensions when described in the book. I've reread section 7.11.1 and it looks to me like it documents ISO C (and probably traditional C too). > If that's C99, I don't > think we can assume all compilers comply with it. I don't think the book that I have documents any of the C99 extensions at all. > Anyway, I know at least one compiler which would print a warning about > large constants being converted to unsigned. Could you test this again? Remember that the expression in question is being evaluated by the C preprocessor, not the C compiler proper. > I think it's best to > avoid warnings, even if they are not mandated by the standard. I don't entirely agree; some compilers produce warnings for perfectly reasonable code. To avoid these warnings, the author of the code sometimes needs to employ artifices which render the code less intelligible to the human reader. For the testsuite, however, it is best to avoid *any* warnings since the testsuite harness often views these as compilation failures and will refuse to run the test otherwise. Kevin