public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
From: Zack Weinberg <zack@codesourcery.com>
To: nobody@gcc.gnu.org
Cc: gcc-prs@gcc.gnu.org,
Subject: Re: preprocessor/5806: The preprocessor evaluates expression s in 64-bit, violating IS C++ 16.1.4
Date: Fri, 01 Mar 2002 13:36:00 -0000	[thread overview]
Message-ID: <20020301213601.14953.qmail@sources.redhat.com> (raw)

The following reply was made to PR preprocessor/5806; it has been noted by GNATS.

From: Zack Weinberg <zack@codesourcery.com>
To: eric_dana@bmc.com
Cc: gcc-gnats@gcc.gnu.org, dick_schoeller@bmc.com,
	Neil Booth <neil@daikokuya.demon.co.uk>
Subject: Re: preprocessor/5806: The preprocessor evaluates expression s in 64-bit, violating IS C++ 16.1.4
Date: Fri, 1 Mar 2002 13:26:51 -0800

 > The preprocessor evaluates expressions using 64-bits, violating ISO
 > C++ 16.1.4 and 5.19. The problems is generic and can be easily
 > reproduced. This causes the 32/64 bit test on Sequent provided
 > header files to be incorrectly parsed.
 
 Yes, you're right.  The preprocessor is obeying ISO C99 6.10.1p3:
 
   ... all signed integer types and all unsigned integer types act as
   if they have the same representation as, respectively, the types
   intmax_t and uintmax_t defined in the header <stdint.h>.
 
 You can see that this is substantially the same as C++ 16.1p4 [cpp.cond]
 except that intmax_t and uintmax_t have been substituted for long and
 unsigned long.  The former are required to be at least 64 bits wide.
 
 The preprocessor ought to do this only in C99 mode; in C++ and
 presumably also C89 mode (I don't have a copy of C89 to check) it
 should use long/unsigned long, which may be 32 bits wide on some
 targets.  Unfortunately, doing this properly requires substantial
 changes to GCC, which are planned, but not currently practical.
 (We're already not quite compliant; preprocessor arithmetic uses the
 _host's_ idea of intmax_t, not the target's.)
 
 Neil - as a stopgap, it occurs to me that we could mask intermediate
 values down to 32 bits when in C89/C++ mode and sizeof(target unsigned
 long) == 4.  Thoughts?
 
 zw
 


             reply	other threads:[~2002-03-01 21:36 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-03-01 13:36 Zack Weinberg [this message]
  -- strict thread matches above, loose matches on Subject: below --
2002-08-05 15:26 Dana, Eric
2002-08-03  0:56 'Zack Weinberg'
2002-05-27 13:35 neil
2002-05-26 12:16 neil
2002-03-25  0:53 neil
2002-03-15  8:56 Dana, Eric
2002-03-14 15:16 'Zack Weinberg'
2002-03-14 13:06 'Neil Booth'
2002-03-14 13:06 Dana, Eric
2002-03-14 11:46 Zack Weinberg
2002-03-01 15:16 Neil Booth
2002-03-01 12:16 eric_dana

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20020301213601.14953.qmail@sources.redhat.com \
    --to=zack@codesourcery.com \
    --cc=gcc-prs@gcc.gnu.org \
    --cc=nobody@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).