This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Re: preprocessor bug in gcc 2.95.2[.1]
- To: meow at pobox dot com
- Subject: Re: preprocessor bug in gcc 2.95.2[.1]
- From: "Zack Weinberg" <zackw at stanford dot edu>
- Date: Wed, 7 Mar 2001 23:35:41 -0800
- Cc: gcc-bugs at gcc dot gnu dot org, lpm at us dot ibm dot com, lpm at pobox dot com
- References: <000201c0a7a0$04298610$13afe220@wlpm>
On Wed, Mar 07, 2001 at 11:18:39PM -0800, Laurent Montaron wrote:
>
> Interesting problem seen on on Intel 32-bit platforms such as cygwin32
> or i386-*-svr4 with GCC 2.95.2 and 2.95.2.1 .
>
> The preprocessor evaluates the expression "(~0UL) == (0xFFFFFFFFUL)" as
> false, whereas it is true on IA-32, where "unsigned long int" is a
> 32-bit quantity.
>
> As a result, the following piece of code (from /usr/include/string.h in
> IBM DYNIX/ptx v4.6) doesn't preprocess properly on Intel platforms:
>
> #if ((~0UL) == 0xffffffffUL)
> typedef unsigned int size_t; /* ILP32 size_t */
> #else
> typedef unsigned long size_t; /* LP64 size_t */
> #endif /* ((~0UL) == 0xffffffffUL) */
>
> Amusingly, the GNU preprocessor evaluates "(~0UL) == (0xFFFFFFFFFFFFFFFFUL)"
> as true, which doesn't make much sense to me.
C99 requires that preprocessor arithmetic be carried out in intmax_t,
which is 64 bits on most targets supported by GCC.
zw