digitalmars.D.bugs - [Issue 21177] New: printf check does not recognize GNU extensions
- d-bugmail puremagic.com (47/48) Aug 18 2020 https://issues.dlang.org/show_bug.cgi?id=21177
https://issues.dlang.org/show_bug.cgi?id=21177 Issue ID: 21177 Summary: printf check does not recognize GNU extensions Product: D Version: D2 Hardware: All OS: Linux Status: NEW Keywords: rejects-valid Severity: regression Priority: P1 Component: dmd Assignee: nobody puremagic.com Reporter: pro.mathias.lang gmail.com 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. --
Aug 18 2020