diff mbox series

hwint: Fix up preprocessor conditions for GCC_PRISZ/fmt_size_t

Message ID ZcsfSfCribhs0tkW@tucnak
State New
Headers show
Series hwint: Fix up preprocessor conditions for GCC_PRISZ/fmt_size_t | expand

Commit Message

Jakub Jelinek Feb. 13, 2024, 7:50 a.m. UTC
Hi!

Using unsigned long long int for fmt_size_t and "ll" for GCC_PRISZ
as broke the gengtype on i686-linux before the libiberty fix is certainly
unexpected.  size_t is there unsigned int, so expected fmt_size_t is
unsigned int (or some other 32-bit type).

The problem was that I was comparing SIZE_MAX against signed maxima,
but SIZE_MAX is unsigned maximum.

Fixed thusly, bootstrapped/regtested on x86_64-linux and i686-linux, ok
for trunk?

2024-02-13  Jakub Jelinek  <jakub@redhat.com>

	* hwint.h (GCC_PRISZ, fmt_size_t): Fix preprocessor conditions,
	instead of comparing SIZE_MAX against INT_MAX and LONG_MAX compare
	it against UINT_MAX and ULONG_MAX.


	Jakub

Comments

Richard Biener Feb. 13, 2024, 9:09 a.m. UTC | #1
On Tue, 13 Feb 2024, Jakub Jelinek wrote:

> Hi!
> 
> Using unsigned long long int for fmt_size_t and "ll" for GCC_PRISZ
> as broke the gengtype on i686-linux before the libiberty fix is certainly
> unexpected.  size_t is there unsigned int, so expected fmt_size_t is
> unsigned int (or some other 32-bit type).
> 
> The problem was that I was comparing SIZE_MAX against signed maxima,
> but SIZE_MAX is unsigned maximum.
> 
> Fixed thusly, bootstrapped/regtested on x86_64-linux and i686-linux, ok
> for trunk?

OK.

> 2024-02-13  Jakub Jelinek  <jakub@redhat.com>
> 
> 	* hwint.h (GCC_PRISZ, fmt_size_t): Fix preprocessor conditions,
> 	instead of comparing SIZE_MAX against INT_MAX and LONG_MAX compare
> 	it against UINT_MAX and ULONG_MAX.
> 
> --- gcc/hwint.h.jj	2024-02-09 11:59:17.444974906 +0100
> +++ gcc/hwint.h	2024-02-12 18:53:51.287281199 +0100
> @@ -120,10 +120,10 @@ typedef HOST_WIDE_INT __gcc_host_wide_in
>     So, instead of doing fprintf ("%zu\n", sizeof (x) * y); use
>     fprintf (HOST_SIZE_T_PRINT_UNSIGNED "\n",
>  	    (fmt_size_t) (sizeof (x) * y));  */
> -#if SIZE_MAX <= INT_MAX
> +#if SIZE_MAX <= UINT_MAX
>  # define GCC_PRISZ ""
>  # define fmt_size_t unsigned int
> -#elif SIZE_MAX <= LONG_MAX
> +#elif SIZE_MAX <= ULONG_MAX
>  # define GCC_PRISZ HOST_LONG_FORMAT
>  # define fmt_size_t unsigned long int
>  #else
> 
> 	Jakub
> 
>
diff mbox series

Patch

--- gcc/hwint.h.jj	2024-02-09 11:59:17.444974906 +0100
+++ gcc/hwint.h	2024-02-12 18:53:51.287281199 +0100
@@ -120,10 +120,10 @@  typedef HOST_WIDE_INT __gcc_host_wide_in
    So, instead of doing fprintf ("%zu\n", sizeof (x) * y); use
    fprintf (HOST_SIZE_T_PRINT_UNSIGNED "\n",
 	    (fmt_size_t) (sizeof (x) * y));  */
-#if SIZE_MAX <= INT_MAX
+#if SIZE_MAX <= UINT_MAX
 # define GCC_PRISZ ""
 # define fmt_size_t unsigned int
-#elif SIZE_MAX <= LONG_MAX
+#elif SIZE_MAX <= ULONG_MAX
 # define GCC_PRISZ HOST_LONG_FORMAT
 # define fmt_size_t unsigned long int
 #else