This is the mail archive of the
cygwin-patches
mailing list for the Cygwin project.
Re: [PATCH] Fix type inconsistencies in stdint.h
- From: Christopher Faylor <cgf-use-the-mailinglist-please at cygwin dot com>
- To: cygwin-patches at cygwin dot com
- Date: Fri, 3 Apr 2009 23:35:45 -0400
- Subject: Re: [PATCH] Fix type inconsistencies in stdint.h
- References: <49D6B8D7.4020907@gmail.com>
- Reply-to: cygwin-patches at cygwin dot com
On Sat, Apr 04, 2009 at 02:33:11AM +0100, Dave Korn wrote:
>
> Hi team,
>
> Upstream GCC just gained the ability to know all about the stdint.h types
>and limits internally. If you're interested in the background, see
>
> http://gcc.gnu.org/ml/gcc/2009-04/msg00000.html
>
>and thread for further reading.
>
> I've submitted the necessary info for the cygwin GCC backend, and now the
>associated testcases show up a few bugs in our stdint.h declarations.
>Basically:-
>
>- uint32_t is "unsigned int", but UINT32_MAX is an unsigned long int constant
>(denoted by the 'UL' suffix).
>- int_least32_t is "long", where INT_LEAST32_MIN and INT_LEAST32_MAX are plain
>(unsuffixed) int constants.
>- int_fast16_t and int_fast32_t are both "long", where INT_FAST16/32_MIN/MAX
>are all plain (unsuffixed) ints.
>- intptr_t is "long" but INTPTR_MIN and INTPTR_MAX lack the "L" suffix and so
>are just ints.
>- size_t is "unsigned int" but the SIZE_MAX constant is unsigned long.
>
> This is bad because if the value of one of these MIN or MAX limits is not of
>the correct integer type matching the integer type it is used in conjunction
>with, there will be an implicit cast operation anytime you assign the
>wrongly-typed value to a variable of the type for which it is supposed to be
>the limit.
>
> The attached patch fixes all these by adjusting only the suffix letters. OK
>for head?
>
>winsup/cygwin/ChangeLog
>
> * include/stdint.h (UINT32_MAX, INT_LEAST32_MIN, INT_LEAST32_MAX,
> INT_FAST16_MIN, INT_FAST32_MIN, INT_FAST16_MAX, INT_FAST32_MAX,
> INTPTR_MIN, INTPTR_MAX, SIZE_MAX): Fix integer constant suffixes.
Many of the changes introduce divergence from Linux. Why is that?
cgf