Paul Eggert wrote:
> I installed the attached patch

Thanks. Stating which conditions produce undefined behaviour goes a long way
at avoiding programmer pitfalls.

> It's OK for 
> behavior to be undefined when the base is bad, just as it's OK for it to 
> be undefined if the string is bad (e.g., when nptr == (char *) &errno).

Strictly speaking, yes. What I meant to avoid are programmer mistakes
that can reasonably likely occur.

> I didn't adjust the recently-added Gnulib test cases even though they're 
> testing what is now documented to be undefined behavior

Yes, this test now merely serves documentation purposes.

Bruno


2024-07-26  Bruno Haible  <br...@clisp.org>

        xstrtol, xstrtoll tests: Improve comment.
        * tests/test-xstrtol.c (main): Clarify that the new test exercises
        undefined behaviour.

diff --git a/tests/test-xstrtol.c b/tests/test-xstrtol.c
index 13ee24219b..2b2b51a47e 100644
--- a/tests/test-xstrtol.c
+++ b/tests/test-xstrtol.c
@@ -67,7 +67,8 @@ main (int argc, char **argv)
     {
       /* Miscellaneous test cases.  */
 
-      /* Test an invalid base.  Reported by Alejandro Colomar.  */
+      /* Test an invalid base (undefined behaviour, as documented in 
xstrtol.h).
+         Reported by Alejandro Colomar.  */
       {
         const char input[] = "k";
         char *endp = NULL;




Reply via email to