public inbox for glibc-cvs@sourceware.org
help / color / mirror / Atom feed
* [glibc/azanella/clang] stdlib: Only enable strtod_l asserts if SIZE_MAX == UINTMAX_MAX
@ 2024-01-29 17:57 Adhemerval Zanella
  0 siblings, 0 replies; 7+ messages in thread
From: Adhemerval Zanella @ 2024-01-29 17:57 UTC (permalink / raw)
  To: glibc-cvs

https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=811e31142befc0500ca547256540abf97dc21a61

commit 811e31142befc0500ca547256540abf97dc21a61
Author: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Date:   Tue Jul 26 08:38:48 2022 -0300

    stdlib: Only enable strtod_l asserts if SIZE_MAX == UINTMAX_MAX
    
    clang on 32 bits where size_t is smaller than intmax_t emits:
    
      strtod_l.c:874:18: error: result of comparison of constant
      9223372036854775807 with expression of type 'size_t' (aka 'unsigned
                        int') is always true
      [-Werror,-Wtautological-constant-out-of-range-compare]
        assert (dig_no <= (uintmax_t) INTMAX_MAX);
        ~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
      ../assert/assert.h:106:11: note: expanded from macro 'assert'
            if (expr)
      \
                ^~~~
    
    So only enable the assert iff SIZE_MAX == UINTMAX_MAX.

Diff:
---
 stdlib/strtod_l.c | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/stdlib/strtod_l.c b/stdlib/strtod_l.c
index be515ce659..d271ed0034 100644
--- a/stdlib/strtod_l.c
+++ b/stdlib/strtod_l.c
@@ -871,7 +871,10 @@ ____STRTOF_INTERNAL (const STRING_TYPE *nptr, STRING_TYPE **endptr, int group,
 	  c = *++cp;
 	}
     }
+
+#if SIZE_MAX == UINTMAX_MAX
   assert (dig_no <= (uintmax_t) INTMAX_MAX);
+#endif
 
   /* Remember start of exponent (if any).  */
   expp = cp;
@@ -901,16 +904,20 @@ ____STRTOF_INTERNAL (const STRING_TYPE *nptr, STRING_TYPE **endptr, int group,
 	    {
 	      if (exp_negative)
 		{
+#if SIZE_MAX == UINTMAX_MAX
 		  assert (int_no <= (uintmax_t) (INTMAX_MAX
 						 + MIN_EXP - MANT_DIG) / 4);
+#endif
 		  exp_limit = -MIN_EXP + MANT_DIG + 4 * (intmax_t) int_no;
 		}
 	      else
 		{
 		  if (int_no)
 		    {
+#if SIZE_MAX == UINTMAX_MAX
 		      assert (lead_zero == 0
 			      && int_no <= (uintmax_t) INTMAX_MAX / 4);
+#endif
 		      exp_limit = MAX_EXP - 4 * (intmax_t) int_no + 3;
 		    }
 		  else if (lead_zero == (size_t) -1)
@@ -921,8 +928,10 @@ ____STRTOF_INTERNAL (const STRING_TYPE *nptr, STRING_TYPE **endptr, int group,
 		    }
 		  else
 		    {
+#if SIZE_MAX == UINTMAX_MAX
 		      assert (lead_zero
 			      <= (uintmax_t) (INTMAX_MAX - MAX_EXP - 3) / 4);
+#endif
 		      exp_limit = (MAX_EXP
 				   + 4 * (intmax_t) lead_zero
 				   + 3);
@@ -933,16 +942,20 @@ ____STRTOF_INTERNAL (const STRING_TYPE *nptr, STRING_TYPE **endptr, int group,
 	    {
 	      if (exp_negative)
 		{
+#if SIZE_MAX == UINTMAX_MAX
 		  assert (int_no
 			  <= (uintmax_t) (INTMAX_MAX + MIN_10_EXP - MANT_DIG));
+#endif
 		  exp_limit = -MIN_10_EXP + MANT_DIG + (intmax_t) int_no;
 		}
 	      else
 		{
 		  if (int_no)
 		    {
+#if SIZE_MAX == UINTMAX_MAX
 		      assert (lead_zero == 0
 			      && int_no <= (uintmax_t) INTMAX_MAX);
+#endif
 		      exp_limit = MAX_10_EXP - (intmax_t) int_no + 1;
 		    }
 		  else if (lead_zero == (size_t) -1)
@@ -953,8 +966,10 @@ ____STRTOF_INTERNAL (const STRING_TYPE *nptr, STRING_TYPE **endptr, int group,
 		    }
 		  else
 		    {
+#if SIZE_MAX == UINTMAX_MAX
 		      assert (lead_zero
 			      <= (uintmax_t) (INTMAX_MAX - MAX_10_EXP - 1));
+#endif
 		      exp_limit = MAX_10_EXP + (intmax_t) lead_zero + 1;
 		    }
 		}

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [glibc/azanella/clang] stdlib: Only enable strtod_l asserts if SIZE_MAX == UINTMAX_MAX
@ 2024-04-17 20:07 Adhemerval Zanella
  0 siblings, 0 replies; 7+ messages in thread
From: Adhemerval Zanella @ 2024-04-17 20:07 UTC (permalink / raw)
  To: glibc-cvs

https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=7bc1bda9b48371f608719be1fb959115db0aafcf

commit 7bc1bda9b48371f608719be1fb959115db0aafcf
Author: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Date:   Tue Jul 26 08:38:48 2022 -0300

    stdlib: Only enable strtod_l asserts if SIZE_MAX == UINTMAX_MAX
    
    clang on 32 bits where size_t is smaller than intmax_t emits:
    
      strtod_l.c:874:18: error: result of comparison of constant
      9223372036854775807 with expression of type 'size_t' (aka 'unsigned
                        int') is always true
      [-Werror,-Wtautological-constant-out-of-range-compare]
        assert (dig_no <= (uintmax_t) INTMAX_MAX);
        ~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
      ../assert/assert.h:106:11: note: expanded from macro 'assert'
            if (expr)
      \
                ^~~~
    
    So only enable the assert iff SIZE_MAX == UINTMAX_MAX.

Diff:
---
 stdlib/strtod_l.c | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/stdlib/strtod_l.c b/stdlib/strtod_l.c
index be515ce659..d271ed0034 100644
--- a/stdlib/strtod_l.c
+++ b/stdlib/strtod_l.c
@@ -871,7 +871,10 @@ ____STRTOF_INTERNAL (const STRING_TYPE *nptr, STRING_TYPE **endptr, int group,
 	  c = *++cp;
 	}
     }
+
+#if SIZE_MAX == UINTMAX_MAX
   assert (dig_no <= (uintmax_t) INTMAX_MAX);
+#endif
 
   /* Remember start of exponent (if any).  */
   expp = cp;
@@ -901,16 +904,20 @@ ____STRTOF_INTERNAL (const STRING_TYPE *nptr, STRING_TYPE **endptr, int group,
 	    {
 	      if (exp_negative)
 		{
+#if SIZE_MAX == UINTMAX_MAX
 		  assert (int_no <= (uintmax_t) (INTMAX_MAX
 						 + MIN_EXP - MANT_DIG) / 4);
+#endif
 		  exp_limit = -MIN_EXP + MANT_DIG + 4 * (intmax_t) int_no;
 		}
 	      else
 		{
 		  if (int_no)
 		    {
+#if SIZE_MAX == UINTMAX_MAX
 		      assert (lead_zero == 0
 			      && int_no <= (uintmax_t) INTMAX_MAX / 4);
+#endif
 		      exp_limit = MAX_EXP - 4 * (intmax_t) int_no + 3;
 		    }
 		  else if (lead_zero == (size_t) -1)
@@ -921,8 +928,10 @@ ____STRTOF_INTERNAL (const STRING_TYPE *nptr, STRING_TYPE **endptr, int group,
 		    }
 		  else
 		    {
+#if SIZE_MAX == UINTMAX_MAX
 		      assert (lead_zero
 			      <= (uintmax_t) (INTMAX_MAX - MAX_EXP - 3) / 4);
+#endif
 		      exp_limit = (MAX_EXP
 				   + 4 * (intmax_t) lead_zero
 				   + 3);
@@ -933,16 +942,20 @@ ____STRTOF_INTERNAL (const STRING_TYPE *nptr, STRING_TYPE **endptr, int group,
 	    {
 	      if (exp_negative)
 		{
+#if SIZE_MAX == UINTMAX_MAX
 		  assert (int_no
 			  <= (uintmax_t) (INTMAX_MAX + MIN_10_EXP - MANT_DIG));
+#endif
 		  exp_limit = -MIN_10_EXP + MANT_DIG + (intmax_t) int_no;
 		}
 	      else
 		{
 		  if (int_no)
 		    {
+#if SIZE_MAX == UINTMAX_MAX
 		      assert (lead_zero == 0
 			      && int_no <= (uintmax_t) INTMAX_MAX);
+#endif
 		      exp_limit = MAX_10_EXP - (intmax_t) int_no + 1;
 		    }
 		  else if (lead_zero == (size_t) -1)
@@ -953,8 +966,10 @@ ____STRTOF_INTERNAL (const STRING_TYPE *nptr, STRING_TYPE **endptr, int group,
 		    }
 		  else
 		    {
+#if SIZE_MAX == UINTMAX_MAX
 		      assert (lead_zero
 			      <= (uintmax_t) (INTMAX_MAX - MAX_10_EXP - 1));
+#endif
 		      exp_limit = MAX_10_EXP + (intmax_t) lead_zero + 1;
 		    }
 		}

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [glibc/azanella/clang] stdlib: Only enable strtod_l asserts if SIZE_MAX == UINTMAX_MAX
@ 2024-04-02 15:53 Adhemerval Zanella
  0 siblings, 0 replies; 7+ messages in thread
From: Adhemerval Zanella @ 2024-04-02 15:53 UTC (permalink / raw)
  To: glibc-cvs

https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=8b0f93ae0acb3f2f9aee5798ed14ccce94a8e134

commit 8b0f93ae0acb3f2f9aee5798ed14ccce94a8e134
Author: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Date:   Tue Jul 26 08:38:48 2022 -0300

    stdlib: Only enable strtod_l asserts if SIZE_MAX == UINTMAX_MAX
    
    clang on 32 bits where size_t is smaller than intmax_t emits:
    
      strtod_l.c:874:18: error: result of comparison of constant
      9223372036854775807 with expression of type 'size_t' (aka 'unsigned
                        int') is always true
      [-Werror,-Wtautological-constant-out-of-range-compare]
        assert (dig_no <= (uintmax_t) INTMAX_MAX);
        ~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
      ../assert/assert.h:106:11: note: expanded from macro 'assert'
            if (expr)
      \
                ^~~~
    
    So only enable the assert iff SIZE_MAX == UINTMAX_MAX.

Diff:
---
 stdlib/strtod_l.c | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/stdlib/strtod_l.c b/stdlib/strtod_l.c
index be515ce659..d271ed0034 100644
--- a/stdlib/strtod_l.c
+++ b/stdlib/strtod_l.c
@@ -871,7 +871,10 @@ ____STRTOF_INTERNAL (const STRING_TYPE *nptr, STRING_TYPE **endptr, int group,
 	  c = *++cp;
 	}
     }
+
+#if SIZE_MAX == UINTMAX_MAX
   assert (dig_no <= (uintmax_t) INTMAX_MAX);
+#endif
 
   /* Remember start of exponent (if any).  */
   expp = cp;
@@ -901,16 +904,20 @@ ____STRTOF_INTERNAL (const STRING_TYPE *nptr, STRING_TYPE **endptr, int group,
 	    {
 	      if (exp_negative)
 		{
+#if SIZE_MAX == UINTMAX_MAX
 		  assert (int_no <= (uintmax_t) (INTMAX_MAX
 						 + MIN_EXP - MANT_DIG) / 4);
+#endif
 		  exp_limit = -MIN_EXP + MANT_DIG + 4 * (intmax_t) int_no;
 		}
 	      else
 		{
 		  if (int_no)
 		    {
+#if SIZE_MAX == UINTMAX_MAX
 		      assert (lead_zero == 0
 			      && int_no <= (uintmax_t) INTMAX_MAX / 4);
+#endif
 		      exp_limit = MAX_EXP - 4 * (intmax_t) int_no + 3;
 		    }
 		  else if (lead_zero == (size_t) -1)
@@ -921,8 +928,10 @@ ____STRTOF_INTERNAL (const STRING_TYPE *nptr, STRING_TYPE **endptr, int group,
 		    }
 		  else
 		    {
+#if SIZE_MAX == UINTMAX_MAX
 		      assert (lead_zero
 			      <= (uintmax_t) (INTMAX_MAX - MAX_EXP - 3) / 4);
+#endif
 		      exp_limit = (MAX_EXP
 				   + 4 * (intmax_t) lead_zero
 				   + 3);
@@ -933,16 +942,20 @@ ____STRTOF_INTERNAL (const STRING_TYPE *nptr, STRING_TYPE **endptr, int group,
 	    {
 	      if (exp_negative)
 		{
+#if SIZE_MAX == UINTMAX_MAX
 		  assert (int_no
 			  <= (uintmax_t) (INTMAX_MAX + MIN_10_EXP - MANT_DIG));
+#endif
 		  exp_limit = -MIN_10_EXP + MANT_DIG + (intmax_t) int_no;
 		}
 	      else
 		{
 		  if (int_no)
 		    {
+#if SIZE_MAX == UINTMAX_MAX
 		      assert (lead_zero == 0
 			      && int_no <= (uintmax_t) INTMAX_MAX);
+#endif
 		      exp_limit = MAX_10_EXP - (intmax_t) int_no + 1;
 		    }
 		  else if (lead_zero == (size_t) -1)
@@ -953,8 +966,10 @@ ____STRTOF_INTERNAL (const STRING_TYPE *nptr, STRING_TYPE **endptr, int group,
 		    }
 		  else
 		    {
+#if SIZE_MAX == UINTMAX_MAX
 		      assert (lead_zero
 			      <= (uintmax_t) (INTMAX_MAX - MAX_10_EXP - 1));
+#endif
 		      exp_limit = MAX_10_EXP + (intmax_t) lead_zero + 1;
 		    }
 		}

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [glibc/azanella/clang] stdlib: Only enable strtod_l asserts if SIZE_MAX == UINTMAX_MAX
@ 2024-02-09 17:31 Adhemerval Zanella
  0 siblings, 0 replies; 7+ messages in thread
From: Adhemerval Zanella @ 2024-02-09 17:31 UTC (permalink / raw)
  To: glibc-cvs

https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=fabaaf9f0a69739657b498cd19317c465f271b51

commit fabaaf9f0a69739657b498cd19317c465f271b51
Author: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Date:   Tue Jul 26 08:38:48 2022 -0300

    stdlib: Only enable strtod_l asserts if SIZE_MAX == UINTMAX_MAX
    
    clang on 32 bits where size_t is smaller than intmax_t emits:
    
      strtod_l.c:874:18: error: result of comparison of constant
      9223372036854775807 with expression of type 'size_t' (aka 'unsigned
                        int') is always true
      [-Werror,-Wtautological-constant-out-of-range-compare]
        assert (dig_no <= (uintmax_t) INTMAX_MAX);
        ~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
      ../assert/assert.h:106:11: note: expanded from macro 'assert'
            if (expr)
      \
                ^~~~
    
    So only enable the assert iff SIZE_MAX == UINTMAX_MAX.

Diff:
---
 stdlib/strtod_l.c | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/stdlib/strtod_l.c b/stdlib/strtod_l.c
index be515ce659..d271ed0034 100644
--- a/stdlib/strtod_l.c
+++ b/stdlib/strtod_l.c
@@ -871,7 +871,10 @@ ____STRTOF_INTERNAL (const STRING_TYPE *nptr, STRING_TYPE **endptr, int group,
 	  c = *++cp;
 	}
     }
+
+#if SIZE_MAX == UINTMAX_MAX
   assert (dig_no <= (uintmax_t) INTMAX_MAX);
+#endif
 
   /* Remember start of exponent (if any).  */
   expp = cp;
@@ -901,16 +904,20 @@ ____STRTOF_INTERNAL (const STRING_TYPE *nptr, STRING_TYPE **endptr, int group,
 	    {
 	      if (exp_negative)
 		{
+#if SIZE_MAX == UINTMAX_MAX
 		  assert (int_no <= (uintmax_t) (INTMAX_MAX
 						 + MIN_EXP - MANT_DIG) / 4);
+#endif
 		  exp_limit = -MIN_EXP + MANT_DIG + 4 * (intmax_t) int_no;
 		}
 	      else
 		{
 		  if (int_no)
 		    {
+#if SIZE_MAX == UINTMAX_MAX
 		      assert (lead_zero == 0
 			      && int_no <= (uintmax_t) INTMAX_MAX / 4);
+#endif
 		      exp_limit = MAX_EXP - 4 * (intmax_t) int_no + 3;
 		    }
 		  else if (lead_zero == (size_t) -1)
@@ -921,8 +928,10 @@ ____STRTOF_INTERNAL (const STRING_TYPE *nptr, STRING_TYPE **endptr, int group,
 		    }
 		  else
 		    {
+#if SIZE_MAX == UINTMAX_MAX
 		      assert (lead_zero
 			      <= (uintmax_t) (INTMAX_MAX - MAX_EXP - 3) / 4);
+#endif
 		      exp_limit = (MAX_EXP
 				   + 4 * (intmax_t) lead_zero
 				   + 3);
@@ -933,16 +942,20 @@ ____STRTOF_INTERNAL (const STRING_TYPE *nptr, STRING_TYPE **endptr, int group,
 	    {
 	      if (exp_negative)
 		{
+#if SIZE_MAX == UINTMAX_MAX
 		  assert (int_no
 			  <= (uintmax_t) (INTMAX_MAX + MIN_10_EXP - MANT_DIG));
+#endif
 		  exp_limit = -MIN_10_EXP + MANT_DIG + (intmax_t) int_no;
 		}
 	      else
 		{
 		  if (int_no)
 		    {
+#if SIZE_MAX == UINTMAX_MAX
 		      assert (lead_zero == 0
 			      && int_no <= (uintmax_t) INTMAX_MAX);
+#endif
 		      exp_limit = MAX_10_EXP - (intmax_t) int_no + 1;
 		    }
 		  else if (lead_zero == (size_t) -1)
@@ -953,8 +966,10 @@ ____STRTOF_INTERNAL (const STRING_TYPE *nptr, STRING_TYPE **endptr, int group,
 		    }
 		  else
 		    {
+#if SIZE_MAX == UINTMAX_MAX
 		      assert (lead_zero
 			      <= (uintmax_t) (INTMAX_MAX - MAX_10_EXP - 1));
+#endif
 		      exp_limit = MAX_10_EXP + (intmax_t) lead_zero + 1;
 		    }
 		}

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [glibc/azanella/clang] stdlib: Only enable strtod_l asserts if SIZE_MAX == UINTMAX_MAX
@ 2024-02-07 14:06 Adhemerval Zanella
  0 siblings, 0 replies; 7+ messages in thread
From: Adhemerval Zanella @ 2024-02-07 14:06 UTC (permalink / raw)
  To: glibc-cvs

https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=77f0aab8c23705e1f986ab71512f8fe4123a2aeb

commit 77f0aab8c23705e1f986ab71512f8fe4123a2aeb
Author: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Date:   Tue Jul 26 08:38:48 2022 -0300

    stdlib: Only enable strtod_l asserts if SIZE_MAX == UINTMAX_MAX
    
    clang on 32 bits where size_t is smaller than intmax_t emits:
    
      strtod_l.c:874:18: error: result of comparison of constant
      9223372036854775807 with expression of type 'size_t' (aka 'unsigned
                        int') is always true
      [-Werror,-Wtautological-constant-out-of-range-compare]
        assert (dig_no <= (uintmax_t) INTMAX_MAX);
        ~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
      ../assert/assert.h:106:11: note: expanded from macro 'assert'
            if (expr)
      \
                ^~~~
    
    So only enable the assert iff SIZE_MAX == UINTMAX_MAX.

Diff:
---
 stdlib/strtod_l.c | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/stdlib/strtod_l.c b/stdlib/strtod_l.c
index be515ce659..d271ed0034 100644
--- a/stdlib/strtod_l.c
+++ b/stdlib/strtod_l.c
@@ -871,7 +871,10 @@ ____STRTOF_INTERNAL (const STRING_TYPE *nptr, STRING_TYPE **endptr, int group,
 	  c = *++cp;
 	}
     }
+
+#if SIZE_MAX == UINTMAX_MAX
   assert (dig_no <= (uintmax_t) INTMAX_MAX);
+#endif
 
   /* Remember start of exponent (if any).  */
   expp = cp;
@@ -901,16 +904,20 @@ ____STRTOF_INTERNAL (const STRING_TYPE *nptr, STRING_TYPE **endptr, int group,
 	    {
 	      if (exp_negative)
 		{
+#if SIZE_MAX == UINTMAX_MAX
 		  assert (int_no <= (uintmax_t) (INTMAX_MAX
 						 + MIN_EXP - MANT_DIG) / 4);
+#endif
 		  exp_limit = -MIN_EXP + MANT_DIG + 4 * (intmax_t) int_no;
 		}
 	      else
 		{
 		  if (int_no)
 		    {
+#if SIZE_MAX == UINTMAX_MAX
 		      assert (lead_zero == 0
 			      && int_no <= (uintmax_t) INTMAX_MAX / 4);
+#endif
 		      exp_limit = MAX_EXP - 4 * (intmax_t) int_no + 3;
 		    }
 		  else if (lead_zero == (size_t) -1)
@@ -921,8 +928,10 @@ ____STRTOF_INTERNAL (const STRING_TYPE *nptr, STRING_TYPE **endptr, int group,
 		    }
 		  else
 		    {
+#if SIZE_MAX == UINTMAX_MAX
 		      assert (lead_zero
 			      <= (uintmax_t) (INTMAX_MAX - MAX_EXP - 3) / 4);
+#endif
 		      exp_limit = (MAX_EXP
 				   + 4 * (intmax_t) lead_zero
 				   + 3);
@@ -933,16 +942,20 @@ ____STRTOF_INTERNAL (const STRING_TYPE *nptr, STRING_TYPE **endptr, int group,
 	    {
 	      if (exp_negative)
 		{
+#if SIZE_MAX == UINTMAX_MAX
 		  assert (int_no
 			  <= (uintmax_t) (INTMAX_MAX + MIN_10_EXP - MANT_DIG));
+#endif
 		  exp_limit = -MIN_10_EXP + MANT_DIG + (intmax_t) int_no;
 		}
 	      else
 		{
 		  if (int_no)
 		    {
+#if SIZE_MAX == UINTMAX_MAX
 		      assert (lead_zero == 0
 			      && int_no <= (uintmax_t) INTMAX_MAX);
+#endif
 		      exp_limit = MAX_10_EXP - (intmax_t) int_no + 1;
 		    }
 		  else if (lead_zero == (size_t) -1)
@@ -953,8 +966,10 @@ ____STRTOF_INTERNAL (const STRING_TYPE *nptr, STRING_TYPE **endptr, int group,
 		    }
 		  else
 		    {
+#if SIZE_MAX == UINTMAX_MAX
 		      assert (lead_zero
 			      <= (uintmax_t) (INTMAX_MAX - MAX_10_EXP - 1));
+#endif
 		      exp_limit = MAX_10_EXP + (intmax_t) lead_zero + 1;
 		    }
 		}

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [glibc/azanella/clang] stdlib: Only enable strtod_l asserts if SIZE_MAX == UINTMAX_MAX
@ 2023-12-21 18:53 Adhemerval Zanella
  0 siblings, 0 replies; 7+ messages in thread
From: Adhemerval Zanella @ 2023-12-21 18:53 UTC (permalink / raw)
  To: glibc-cvs

https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=79910ce8c4117faefee27cfff9ec1cb9e33e10cc

commit 79910ce8c4117faefee27cfff9ec1cb9e33e10cc
Author: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Date:   Tue Jul 26 08:38:48 2022 -0300

    stdlib: Only enable strtod_l asserts if SIZE_MAX == UINTMAX_MAX
    
    clang on 32 bits where size_t is smaller than intmax_t emits:
    
      strtod_l.c:874:18: error: result of comparison of constant
      9223372036854775807 with expression of type 'size_t' (aka 'unsigned
                        int') is always true
      [-Werror,-Wtautological-constant-out-of-range-compare]
        assert (dig_no <= (uintmax_t) INTMAX_MAX);
        ~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
      ../assert/assert.h:106:11: note: expanded from macro 'assert'
            if (expr)
      \
                ^~~~
    
    So only enable the assert iff SIZE_MAX == UINTMAX_MAX.

Diff:
---
 stdlib/strtod_l.c | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/stdlib/strtod_l.c b/stdlib/strtod_l.c
index c5cbb39dff..7d79ff2241 100644
--- a/stdlib/strtod_l.c
+++ b/stdlib/strtod_l.c
@@ -871,7 +871,10 @@ ____STRTOF_INTERNAL (const STRING_TYPE *nptr, STRING_TYPE **endptr, int group,
 	  c = *++cp;
 	}
     }
+
+#if SIZE_MAX == UINTMAX_MAX
   assert (dig_no <= (uintmax_t) INTMAX_MAX);
+#endif
 
   /* Remember start of exponent (if any).  */
   expp = cp;
@@ -901,16 +904,20 @@ ____STRTOF_INTERNAL (const STRING_TYPE *nptr, STRING_TYPE **endptr, int group,
 	    {
 	      if (exp_negative)
 		{
+#if SIZE_MAX == UINTMAX_MAX
 		  assert (int_no <= (uintmax_t) (INTMAX_MAX
 						 + MIN_EXP - MANT_DIG) / 4);
+#endif
 		  exp_limit = -MIN_EXP + MANT_DIG + 4 * (intmax_t) int_no;
 		}
 	      else
 		{
 		  if (int_no)
 		    {
+#if SIZE_MAX == UINTMAX_MAX
 		      assert (lead_zero == 0
 			      && int_no <= (uintmax_t) INTMAX_MAX / 4);
+#endif
 		      exp_limit = MAX_EXP - 4 * (intmax_t) int_no + 3;
 		    }
 		  else if (lead_zero == (size_t) -1)
@@ -921,8 +928,10 @@ ____STRTOF_INTERNAL (const STRING_TYPE *nptr, STRING_TYPE **endptr, int group,
 		    }
 		  else
 		    {
+#if SIZE_MAX == UINTMAX_MAX
 		      assert (lead_zero
 			      <= (uintmax_t) (INTMAX_MAX - MAX_EXP - 3) / 4);
+#endif
 		      exp_limit = (MAX_EXP
 				   + 4 * (intmax_t) lead_zero
 				   + 3);
@@ -933,16 +942,20 @@ ____STRTOF_INTERNAL (const STRING_TYPE *nptr, STRING_TYPE **endptr, int group,
 	    {
 	      if (exp_negative)
 		{
+#if SIZE_MAX == UINTMAX_MAX
 		  assert (int_no
 			  <= (uintmax_t) (INTMAX_MAX + MIN_10_EXP - MANT_DIG));
+#endif
 		  exp_limit = -MIN_10_EXP + MANT_DIG + (intmax_t) int_no;
 		}
 	      else
 		{
 		  if (int_no)
 		    {
+#if SIZE_MAX == UINTMAX_MAX
 		      assert (lead_zero == 0
 			      && int_no <= (uintmax_t) INTMAX_MAX);
+#endif
 		      exp_limit = MAX_10_EXP - (intmax_t) int_no + 1;
 		    }
 		  else if (lead_zero == (size_t) -1)
@@ -953,8 +966,10 @@ ____STRTOF_INTERNAL (const STRING_TYPE *nptr, STRING_TYPE **endptr, int group,
 		    }
 		  else
 		    {
+#if SIZE_MAX == UINTMAX_MAX
 		      assert (lead_zero
 			      <= (uintmax_t) (INTMAX_MAX - MAX_10_EXP - 1));
+#endif
 		      exp_limit = MAX_10_EXP + (intmax_t) lead_zero + 1;
 		    }
 		}

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [glibc/azanella/clang] stdlib: Only enable strtod_l asserts if SIZE_MAX == UINTMAX_MAX
@ 2023-09-28 17:51 Adhemerval Zanella
  0 siblings, 0 replies; 7+ messages in thread
From: Adhemerval Zanella @ 2023-09-28 17:51 UTC (permalink / raw)
  To: glibc-cvs

https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=55641107bc240f03631aacac79c922d2a56278f5

commit 55641107bc240f03631aacac79c922d2a56278f5
Author: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Date:   Tue Jul 26 08:38:48 2022 -0300

    stdlib: Only enable strtod_l asserts if SIZE_MAX == UINTMAX_MAX
    
    clang on 32 bits where size_t is smaller than intmax_t emits:
    
      strtod_l.c:874:18: error: result of comparison of constant
      9223372036854775807 with expression of type 'size_t' (aka 'unsigned
                        int') is always true
      [-Werror,-Wtautological-constant-out-of-range-compare]
        assert (dig_no <= (uintmax_t) INTMAX_MAX);
        ~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
      ../assert/assert.h:106:11: note: expanded from macro 'assert'
            if (expr)
      \
                ^~~~
    
    So only enable the assert iff SIZE_MAX == UINTMAX_MAX.

Diff:
---
 stdlib/strtod_l.c | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/stdlib/strtod_l.c b/stdlib/strtod_l.c
index c5cbb39dff..7d79ff2241 100644
--- a/stdlib/strtod_l.c
+++ b/stdlib/strtod_l.c
@@ -871,7 +871,10 @@ ____STRTOF_INTERNAL (const STRING_TYPE *nptr, STRING_TYPE **endptr, int group,
 	  c = *++cp;
 	}
     }
+
+#if SIZE_MAX == UINTMAX_MAX
   assert (dig_no <= (uintmax_t) INTMAX_MAX);
+#endif
 
   /* Remember start of exponent (if any).  */
   expp = cp;
@@ -901,16 +904,20 @@ ____STRTOF_INTERNAL (const STRING_TYPE *nptr, STRING_TYPE **endptr, int group,
 	    {
 	      if (exp_negative)
 		{
+#if SIZE_MAX == UINTMAX_MAX
 		  assert (int_no <= (uintmax_t) (INTMAX_MAX
 						 + MIN_EXP - MANT_DIG) / 4);
+#endif
 		  exp_limit = -MIN_EXP + MANT_DIG + 4 * (intmax_t) int_no;
 		}
 	      else
 		{
 		  if (int_no)
 		    {
+#if SIZE_MAX == UINTMAX_MAX
 		      assert (lead_zero == 0
 			      && int_no <= (uintmax_t) INTMAX_MAX / 4);
+#endif
 		      exp_limit = MAX_EXP - 4 * (intmax_t) int_no + 3;
 		    }
 		  else if (lead_zero == (size_t) -1)
@@ -921,8 +928,10 @@ ____STRTOF_INTERNAL (const STRING_TYPE *nptr, STRING_TYPE **endptr, int group,
 		    }
 		  else
 		    {
+#if SIZE_MAX == UINTMAX_MAX
 		      assert (lead_zero
 			      <= (uintmax_t) (INTMAX_MAX - MAX_EXP - 3) / 4);
+#endif
 		      exp_limit = (MAX_EXP
 				   + 4 * (intmax_t) lead_zero
 				   + 3);
@@ -933,16 +942,20 @@ ____STRTOF_INTERNAL (const STRING_TYPE *nptr, STRING_TYPE **endptr, int group,
 	    {
 	      if (exp_negative)
 		{
+#if SIZE_MAX == UINTMAX_MAX
 		  assert (int_no
 			  <= (uintmax_t) (INTMAX_MAX + MIN_10_EXP - MANT_DIG));
+#endif
 		  exp_limit = -MIN_10_EXP + MANT_DIG + (intmax_t) int_no;
 		}
 	      else
 		{
 		  if (int_no)
 		    {
+#if SIZE_MAX == UINTMAX_MAX
 		      assert (lead_zero == 0
 			      && int_no <= (uintmax_t) INTMAX_MAX);
+#endif
 		      exp_limit = MAX_10_EXP - (intmax_t) int_no + 1;
 		    }
 		  else if (lead_zero == (size_t) -1)
@@ -953,8 +966,10 @@ ____STRTOF_INTERNAL (const STRING_TYPE *nptr, STRING_TYPE **endptr, int group,
 		    }
 		  else
 		    {
+#if SIZE_MAX == UINTMAX_MAX
 		      assert (lead_zero
 			      <= (uintmax_t) (INTMAX_MAX - MAX_10_EXP - 1));
+#endif
 		      exp_limit = MAX_10_EXP + (intmax_t) lead_zero + 1;
 		    }
 		}

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2024-04-17 20:07 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-01-29 17:57 [glibc/azanella/clang] stdlib: Only enable strtod_l asserts if SIZE_MAX == UINTMAX_MAX Adhemerval Zanella
  -- strict thread matches above, loose matches on Subject: below --
2024-04-17 20:07 Adhemerval Zanella
2024-04-02 15:53 Adhemerval Zanella
2024-02-09 17:31 Adhemerval Zanella
2024-02-07 14:06 Adhemerval Zanella
2023-12-21 18:53 Adhemerval Zanella
2023-09-28 17:51 Adhemerval Zanella

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).