From 3109fd2f288973e9e7596f03fedcf60835589cfc 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 --- 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 c68c8c10ac9160..f512408e9e239f 100644 --- a/stdlib/Printf/src/Printf.jl +++ b/stdlib/Printf/src/Printf.jl @@ -601,7 +601,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 da4e8f9a78fe10..71da6b03b34bb2 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