[PATCH] Fix type inconsistencies in stdint.h

Dave Korn dave.korn.cygwin@googlemail.com
Sat Apr 4 01:23:00 GMT 2009


    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.

    cheers,
      DaveK
-------------- next part --------------
A non-text attachment was scrubbed...
Name: cygwin-gcc-stdint-types-patch.diff
Type: text/x-c
Size: 2222 bytes
Desc: not available
URL: <http://cygwin.com/pipermail/cygwin-patches/attachments/20090404/17976f98/attachment.bin>


More information about the Cygwin-patches mailing list