From 0d9163b561a5f809b895b9cd8893d1a010197284 Mon Sep 17 00:00:00 2001 From: Jacob Quinn Date: Fri, 2 Apr 2021 11:38:47 -0600 Subject: [PATCH 1/2] Fix #40318 by using UInt to convert instead of Int on Ptr --- stdlib/Printf/src/Printf.jl | 2 +- stdlib/Printf/test/runtests.jl | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/stdlib/Printf/src/Printf.jl b/stdlib/Printf/src/Printf.jl index ac57f95ec6bb9..2b620873bd61a 100644 --- a/stdlib/Printf/src/Printf.jl +++ b/stdlib/Printf/src/Printf.jl @@ -547,7 +547,7 @@ const __BIG_FLOAT_MAX__ = 8192 end # pointers -fmt(buf, pos, arg, spec::Spec{Pointer}) = fmt(buf, pos, Int(arg), ptrfmt(spec, arg)) +fmt(buf, pos, arg, spec::Spec{Pointer}) = fmt(buf, pos, UInt(arg), ptrfmt(spec, arg)) # old Printf compat function fix_dec end diff --git a/stdlib/Printf/test/runtests.jl b/stdlib/Printf/test/runtests.jl index d38c90734d4f1..498302a20ed0c 100644 --- a/stdlib/Printf/test/runtests.jl +++ b/stdlib/Printf/test/runtests.jl @@ -19,6 +19,9 @@ using Test, Printf @test (@sprintf "%-20p" C_NULL) == "0x00000000 " end + #40318 + @test @sprintf("%p", 0xfffffffffffe0000) == "0xfffffffffffe0000" + end @testset "%a" begin From 5332d7d4e40ca2189e4ab597bf937f272f471bda Mon Sep 17 00:00:00 2001 From: Jacob Quinn Date: Fri, 2 Apr 2021 13:41:29 -0600 Subject: [PATCH 2/2] Fix 32-bit --- stdlib/Printf/src/Printf.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stdlib/Printf/src/Printf.jl b/stdlib/Printf/src/Printf.jl index 2b620873bd61a..e00b6becbb0f1 100644 --- a/stdlib/Printf/src/Printf.jl +++ b/stdlib/Printf/src/Printf.jl @@ -547,7 +547,7 @@ const __BIG_FLOAT_MAX__ = 8192 end # pointers -fmt(buf, pos, arg, spec::Spec{Pointer}) = fmt(buf, pos, UInt(arg), ptrfmt(spec, arg)) +fmt(buf, pos, arg, spec::Spec{Pointer}) = fmt(buf, pos, UInt64(arg), ptrfmt(spec, arg)) # old Printf compat function fix_dec end