[Git][ghc/ghc][master] testsuite/T20137: Avoid impl.-defined behavior

Marge Bot (@marge-bot) gitlab at gitlab.haskell.org
Mon Apr 24 16:19:27 UTC 2023



Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC


Commits:
787c6e8c by Ben Gamari at 2023-04-24T12:19:06-04:00
testsuite/T20137: Avoid impl.-defined behavior

Previously we would cast pointers to uint64_t. However, implementations
are allowed to either zero- or sign-extend such casts. Instead cast to
uintptr_t to avoid this.

Fixes #23247.

- - - - -


2 changed files:

- testsuite/tests/codeGen/should_run/T20137/T20137.stdout-ws-32
- testsuite/tests/codeGen/should_run/T20137/T20137C.c


Changes:

=====================================
testsuite/tests/codeGen/should_run/T20137/T20137.stdout-ws-32
=====================================
@@ -5,9 +5,9 @@
 5
 6
 77777777
-ffffffff88888888
-ffffffff99999999
-ffffffffaaaaaaaa
-ffffffffbbbbbbbb
+88888888
+99999999
+aaaaaaaa
+bbbbbbbb
 cccccccc
-ffffffffdddddddd
+dddddddd


=====================================
testsuite/tests/codeGen/should_run/T20137/T20137C.c
=====================================
@@ -16,19 +16,19 @@ runInteractiveProcess (char *const * args,
 {
         // N.B. We don't use %p here since the rendering of this varies across
         // libc implementations
-        printf("%" PRIx64 "\n", (uint64_t) args);
-        printf("%" PRIx64 "\n", (uint64_t) workingDirectory);
-        printf("%" PRIx64 "\n", (uint64_t) environment);
+        printf("%" PRIxPTR "\n", (uintptr_t) args);
+        printf("%" PRIxPTR "\n", (uintptr_t) workingDirectory);
+        printf("%" PRIxPTR "\n", (uintptr_t) environment);
         printf("%x\n", fdStdIn);
         printf("%x\n", fdStdOut);
         printf("%x\n", fdStdErr);
-        printf("%" PRIx64 "\n", (uint64_t) pfdStdInput);
-        printf("%" PRIx64 "\n", (uint64_t) pfdStdOutput);
-        printf("%" PRIx64 "\n", (uint64_t) pfdStdError);
-        printf("%" PRIx64 "\n", (uint64_t) childGroup);
-        printf("%" PRIx64 "\n", (uint64_t) childUser);
+        printf("%" PRIxPTR "\n", (uintptr_t) pfdStdInput);
+        printf("%" PRIxPTR "\n", (uintptr_t) pfdStdOutput);
+        printf("%" PRIxPTR "\n", (uintptr_t) pfdStdError);
+        printf("%" PRIxPTR "\n", (uintptr_t) childGroup);
+        printf("%" PRIxPTR "\n", (uintptr_t) childUser);
         printf("%x\n", flags);
-        printf("%" PRIx64 "\n", (uint64_t) failed_doing);
+        printf("%" PRIxPTR "\n", (uintptr_t) failed_doing);
         return 0;
 }
 



View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/787c6e8c5b96c95ead6cc7c213d12c5983975084

-- 
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/787c6e8c5b96c95ead6cc7c213d12c5983975084
You're receiving this email because of your account on gitlab.haskell.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/ghc-commits/attachments/20230424/afb39faf/attachment-0001.html>


More information about the ghc-commits mailing list