www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Deprecation: argument `ul` for format specification `"%lu"` must be

reply ParticlePeter <ParticlePeter gmx.de> writes:
void main()  {
     import core.stdc.stdio : printf;
     ulong ul = 0;
     printf( "%lu\n", ul );
}

Tested on dmd 2.093 and 2.093.1 (noticed on later first time), 
with flag -m64.
Same message when format specifier is %u.

Is this intended behavior?
Aug 25 2020
parent reply Mathias LANG <geod24 gmail.com> writes:
On Tuesday, 25 August 2020 at 08:14:23 UTC, ParticlePeter wrote:
 void main()  {
     import core.stdc.stdio : printf;
     ulong ul = 0;
     printf( "%lu\n", ul );
 }

 Tested on dmd 2.093 and 2.093.1 (noticed on later first time), 
 with flag -m64.
 Same message when format specifier is %u.

 Is this intended behavior?
Yes. You should use `llu`. https://en.wikipedia.org/wiki/C_data_types Also those questions are better suited for the `D.learn` forum.
Aug 25 2020
parent reply ParticlePeter <ParticlePeter gmx.de> writes:
On Tuesday, 25 August 2020 at 09:06:27 UTC, Mathias LANG wrote:
 On Tuesday, 25 August 2020 at 08:14:23 UTC, ParticlePeter wrote:
 void main()  {
     import core.stdc.stdio : printf;
     ulong ul = 0;
     printf( "%lu\n", ul );
 }

 Tested on dmd 2.093 and 2.093.1 (noticed on later first time), 
 with flag -m64.
 Same message when format specifier is %u.

 Is this intended behavior?
Yes. You should use `llu`. https://en.wikipedia.org/wiki/C_data_types
Thanks, I oversaw that a ulong means unsigned long long.
 Also those questions are better suited for the `D.learn` forum.
What makes you think I am learning (printf), and what do you mean by 'those questions' ? The code I am talking about is unchanged since at least, dmd 2.086, now I am getting the Deprecation message.
Aug 25 2020
parent reply Walter Bright <newshound2 digitalmars.com> writes:
On 8/25/2020 2:28 AM, ParticlePeter wrote:
 The code I am talking about is unchanged since at least, dmd 2.086, 
 now I am getting the Deprecation message.
That's because printf format checking is a new feature. Your code was actually broken before, although it appeared to work. It would likely have failed more obviously if there were more argments after ul, or if your machine was bigendian. This change uncovered a lot of similar latent bugs in programs.
Aug 26 2020
parent Jonathan M Davis <newsgroup.d jmdavisprog.com> writes:
On Wednesday, August 26, 2020 10:28:13 PM MDT Walter Bright via Digitalmars-d 
wrote:
 On 8/25/2020 2:28 AM, ParticlePeter wrote:
 The code I am talking about is unchanged since at least, dmd 2.086,
 now I am getting the Deprecation message.
That's because printf format checking is a new feature. Your code was actually broken before, although it appeared to work. It would likely have failed more obviously if there were more argments after ul, or if your machine was bigendian. This change uncovered a lot of similar latent bugs in programs.
It's the kind of breaking change that's actually nice, since it's finding bugs for you (like when fallthrough on switch statements was banned outside of empty case statements). - Jonathan M Davis
Aug 31 2020