[libc-commits] [PATCH] D140577: [libc][obvious] fix errno for 32 bit long test

Michael Jones via Phabricator via libc-commits libc-commits at lists.llvm.org
Thu Dec 22 12:02:44 PST 2022


This revision was not accepted when it landed; it landed in state "Needs Review".
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGa484c9bd2ea9: [libc][obvious] fix errno for 32 bit long test (authored by michaelrj).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D140577/new/

https://reviews.llvm.org/D140577

Files:
  libc/test/src/stdlib/StrtolTest.h


Index: libc/test/src/stdlib/StrtolTest.h
===================================================================
--- libc/test/src/stdlib/StrtolTest.h
+++ libc/test/src/stdlib/StrtolTest.h
@@ -70,9 +70,13 @@
     // wide, strtol will return LONG_MAX.
     const char *bigger_number = "12345678900";
     errno = 0;
-    ASSERT_EQ(func(bigger_number, &str_end, 10),
-              ((sizeof(ReturnT) < 8) ? T_MAX : ReturnT(12345678900)));
-    ASSERT_EQ(errno, 0);
+    if constexpr (sizeof(ReturnT) < 8) {
+      ASSERT_EQ(func(bigger_number, &str_end, 10), T_MAX);
+      ASSERT_EQ(errno, ERANGE);
+    } else {
+      ASSERT_EQ(func(bigger_number, &str_end, 10), ReturnT(12345678900));
+      ASSERT_EQ(errno, 0);
+    }
     EXPECT_EQ(str_end - bigger_number, ptrdiff_t(11));
 
     const char *too_big_number = "123456789012345678901";


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D140577.484923.patch
Type: text/x-patch
Size: 835 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libc-commits/attachments/20221222/9ef85d65/attachment.bin>


More information about the libc-commits mailing list