Bug 21177 – printf check does not recognize GNU extensions
Status
RESOLVED
Resolution
FIXED
Severity
regression
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
Linux
Creation time
2020-08-19T06:35:00Z
Last change time
2021-02-13T12:29:52Z
Keywords
pull, rejects-valid
Assigned to
No Owner
Creator
Mathias LANG
Comments
Comment #0 by pro.mathias.lang — 2020-08-19T06:35:00Z
I have some platform-specific server code (it only runs on Ubuntu / Glibc).
In this code, the `%m` format is used with fscanf:
```
/*
* Special fscanf format tokens:
* - The leading ' ' skips leading white space.
* - %n stores the current position in the input string in the
* argument so that
* channel_name.length = name_end - name_start.
* - %m matches a string, stores it in a buffer allocated by
* malloc and stores a pointer to that buffer in the
* argument.
* - [_0-9a-zA-Z-] makes %m match only strings that consist of
* the characters '_', '0'-'9', 'a'-'z', 'A'-'Z' or '-',
* which ensures the string is a valid dls channel name.
*/
n = fscanf(this.stream,
" %n%m[_0-9a-zA-Z-]%n %lu %lu".ptr,
&name_start, &channel_name, &name_end,
&bucket_start, &bucket_offset)
```
Source: https://github.com/sociomantic-tsunami/dlsnode/blob/26a8037827a653e7827ead19d693357e2c808723/src/dlsnode/storage/checkpoint/CheckpointFile.d#L203-L219
While trying to update to the latest DMD, I get a deprecation message.
From a quick google search, I could find the following extension:
- `%m` for printf => Print output of strerror(errno) (no argument)
- `%a` for scanf
- `%m` for scanf
Note that a "smart" fix would only warn about those when not using `CRuntime_Glibc`. Or just accept that GNU extensions are widespread and let those slide.
Comment #1 by dlang-bot — 2021-01-03T17:47:22Z
@Luhrel created dlang/dmd pull request #12094 "Fix issue 21177 - printf check does not recognize GNU extensions" fixing this issue:
- Fix issue 21177
https://github.com/dlang/dmd/pull/12094
Comment #2 by ibuclaw — 2021-01-03T21:01:44Z
Why is this a regression when it's a feature request?
Comment #3 by pro.mathias.lang — 2021-01-03T23:56:24Z
A new feature is triggering deprecation messages in perfectly working code.
Yes, it is a regression, as all false-positives are.
Comment #4 by dlang-bot — 2021-01-07T15:04:16Z
dlang/dmd pull request #12094 "Fix issue 21177 - printf check does not recognize GNU extensions" was merged into stable:
- 4463ae26882107cfcf9b336fd063ea99f0d983f5 by Luhrel:
Fix issue 21177 - printf check does not recognize GNU extensions
https://github.com/dlang/dmd/pull/12094
Comment #5 by dlang-bot — 2021-02-13T12:29:52Z
dlang/dmd pull request #12195 "Merge stable" was merged into master:
- 3431e98cb0720b7bdb325af62c0d8dd1d4ce4e0a by Lucien Perregaux:
Fix issue 21177 - printf check does not recognize GNU extensions (#12094)
https://github.com/dlang/dmd/pull/12195