From ef7bf2e7f41b6ce9121de6198ec87aa71477e153 Mon Sep 17 00:00:00 2001 From: Jacob Quinn Date: Fri, 2 Apr 2021 11:38:47 -0600 Subject: [PATCH] Fix #40318 by using UInt to convert instead of Int on Ptr (cherry picked from commit 0d9163b561a5f809b895b9cd8893d1a010197284) --- 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 ac57f95ec6bb96..2b620873bd61a1 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 c74739d66ba514..f6645464b47978 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