Bug 23475 – confusing printf deprecation message with ulong/long on Windows

Status
RESOLVED
Resolution
FIXED
Severity
enhancement
Priority
P4
Component
dmd
Product
D
Version
D2
Platform
x86
OS
Windows
Creation time
2022-11-10T18:15:28Z
Last change time
2023-05-04T17:34:10Z
Keywords
diagnostic, pull
Assigned to
No Owner
Creator
Nick Treleaven

Comments

Comment #0 by nick — 2022-11-10T18:15:28Z
On my Windows 8 system: pragma(msg, size_t.sizeof); // 4 pragma(msg, ulong.sizeof); // 8 printf("%lu", ulong.init); printfulong.d(33): Deprecation: argument `0LU` for format specification `"%lu"` must be `uint`, not `ulong` Surely %lu is the correct format specifier for ulong?! Same for long: printf("%ld", long.init); printfulong.d(34): Deprecation: argument `0L` for format specification `"%ld"` must be `int`, not `long`
Comment #1 by kinke — 2022-11-10T18:56:50Z
Nope - Microsoft chose 32-bit for `long` (even when targeting 64-bit Windows!). You need to use `%lld` for `long long`, which is always 64-bit for all targets I know of.
Comment #2 by nick — 2022-11-13T16:06:09Z
Huh? I already showed that ulong is 64 bit on my windows system.
Comment #3 by nick — 2022-11-13T16:14:32Z
Well I think the error message could be less confusing anyway.
Comment #4 by nick — 2022-11-13T16:19:13Z
Well I think the error message could be less confusing anyway.
Comment #5 by kinke — 2022-11-13T18:46:24Z
(In reply to Nick Treleaven from comment #2) > Huh? I already showed that ulong is 64 bit on my windows system. You're calling a C function, which couldn't care less about D well-defining long as 64-bit on all targets.
Comment #6 by dlang-bot — 2022-11-14T14:34:51Z
@ntrel created dlang/dmd pull request #14641 "Fix Issue 23475 - confusing printf deprecation message with ulong/lon…" fixing this issue: - Fix Issue 23475 - confusing printf deprecation message with ulong/long on Windows https://github.com/dlang/dmd/pull/14641
Comment #7 by nick — 2022-11-14T14:36:38Z
(In reply to kinke from comment #5) > You're calling a C function, which couldn't care less about D well-defining > long as 64-bit on all targets. Yes, thanks for the tip about %lld.
Comment #8 by dlang-bot — 2023-05-04T17:34:10Z
dlang/dmd pull request #14641 "Fix Issue 23475 - confusing printf deprecation message with ulong/lon…" was merged into master: - 286bf003cc2b9a69ad5de39d319aa9383716ada6 by Nick Treleaven: Fix Issue 23475 - confusing printf deprecation message with ulong/long on Windows https://github.com/dlang/dmd/pull/14641