Thread overview | |||||||
---|---|---|---|---|---|---|---|
|
August 25, 2020 Deprecation: argument `ul` for format specification `"%lu"` must be `int`, not `ulong` | ||||
---|---|---|---|---|
| ||||
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? |
August 25, 2020 Re: Deprecation: argument `ul` for format specification `"%lu"` must be `int`, not `ulong` | ||||
---|---|---|---|---|
| ||||
Posted in reply to ParticlePeter | 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. |
August 25, 2020 Re: Deprecation: argument `ul` for format specification `"%lu"` must be `int`, not `ulong` | ||||
---|---|---|---|---|
| ||||
Posted in reply to Mathias LANG | 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. |
August 26, 2020 Re: Deprecation: argument `ul` for format specification `"%lu"` must be `int`, not `ulong` | ||||
---|---|---|---|---|
| ||||
Posted in reply to ParticlePeter | 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.
|
August 31, 2020 Re: Deprecation: argument `ul` for format specification `"%lu"` must be `int`, not `ulong` | ||||
---|---|---|---|---|
| ||||
Posted in reply to Walter Bright | 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
|
Copyright © 1999-2021 by the D Language Foundation