public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* Lots of bugs in <limits.h> ?
@ 2002-12-30 14:47 Neil Booth
  2002-12-30 15:46 ` Joseph S. Myers
  0 siblings, 1 reply; 3+ messages in thread
From: Neil Booth @ 2002-12-30 14:47 UTC (permalink / raw)
  To: gcc

Reading the C standard carefully leads me to believe that the macros
like

UINT_MAX, LONG_MIN

etc. should be values, and not typed integer constants like "65535U"
nor expressions like "(-LONG_MAX - 1)".

My attention was drawn to this fact by a comment on Dinkumware's
website about Glibc's not being standards conforming because if such
macros are passed to other macros like UINT64_C they produce
preprocessor or parser errors because suffixes like "LL" are appended
to the original macros.  My reading of the C standard is that it is
indeed intended that this should be possible.

Do others agree?

If so, for GCC we need to fix <limits.h>, as well as some bits of
c-common.c.

Neil.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Lots of bugs in <limits.h> ?
  2002-12-30 14:47 Lots of bugs in <limits.h> ? Neil Booth
@ 2002-12-30 15:46 ` Joseph S. Myers
  2002-12-30 18:01   ` Neil Booth
  0 siblings, 1 reply; 3+ messages in thread
From: Joseph S. Myers @ 2002-12-30 15:46 UTC (permalink / raw)
  To: Neil Booth; +Cc: gcc

On Mon, 30 Dec 2002, Neil Booth wrote:

> Reading the C standard carefully leads me to believe that the macros
> like
> 
> UINT_MAX, LONG_MIN
> 
> etc. should be values, and not typed integer constants like "65535U"
> nor expressions like "(-LONG_MAX - 1)".

They are "constant expressions suitable for use in #if preprocessing
directives", "expressions that have the same type as would an expression
that is an object of the corresponding type converted according to the
integer promotions", as required by C99.  As I've already pointed out on
libc-alpha
<http://sources.redhat.com/ml/libc-alpha/2002-12/msg00088.html>,
Dinkumware's page is simply wrong about the requirements for the
<stdint.h> macros, which are specified as applying to constants (not
constant expressions), both before and after TC1.

-- 
Joseph S. Myers
jsm28@cam.ac.uk

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Lots of bugs in <limits.h> ?
  2002-12-30 15:46 ` Joseph S. Myers
@ 2002-12-30 18:01   ` Neil Booth
  0 siblings, 0 replies; 3+ messages in thread
From: Neil Booth @ 2002-12-30 18:01 UTC (permalink / raw)
  To: Joseph S. Myers; +Cc: gcc

> > Reading the C standard carefully leads me to believe that the macros
> > like
> > 
> > UINT_MAX, LONG_MIN
> > 
> > etc. should be values, and not typed integer constants like "65535U"
> > nor expressions like "(-LONG_MAX - 1)".
> 
> They are "constant expressions suitable for use in #if preprocessing
> directives", "expressions that have the same type as would an expression
> that is an object of the corresponding type converted according to the
> integer promotions", as required by C99.  As I've already pointed out on
> libc-alpha
> <http://sources.redhat.com/ml/libc-alpha/2002-12/msg00088.html>,
> Dinkumware's page is simply wrong about the requirements for the
> <stdint.h> macros, which are specified as applying to constants (not
> constant expressions), both before and after TC1.

Indeed.  I'd been too obsessed with the use of the word "value" and
the example values given, which don't contain suffixes.  The word
"value" is also used in the description of the UINTMAX_C etc. macros,
which is confusing.

The examples should be updated to not use "value" and have a suffix IMO.

Neil.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2002-12-30 20:58 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-12-30 14:47 Lots of bugs in <limits.h> ? Neil Booth
2002-12-30 15:46 ` Joseph S. Myers
2002-12-30 18:01   ` Neil Booth

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).