Bug 23031 – importC: hex character escapes should be variable length

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2022-04-17T13:17:31Z
Last change time
2022-04-20T08:29:44Z
Keywords
ImportC, pull
Assigned to
No Owner
Creator
duser

Comments

Comment #0 by duser — 2022-04-17T13:17:31Z
#include <assert.h> _Static_assert(sizeof("\x1") == 2, ""); // Error: escape hex sequence has 1 hex digits instead of 2 _Static_assert(sizeof("\x20") == 2, ""); _Static_assert(sizeof("\x020") == 2, ""); // fails, parsed as [0x02, '0'] _Static_assert(sizeof("\x0020") == 2, ""); // fails, parsed as [0x00, '2', '0'] int main() { assert( "\x1"[0] == 1 ); // Error: escape hex sequence has 1 hex digits instead of 2 assert( "\x20"[0] == 0x20 ); assert( "\x020"[0] == 0x20 ); assert( "\x0020"[0] == 0x20 ); } http://port70.net/~nsz/c/c11/n1570.html#6.4.4.4p7 > 7. Each octal or hexadecimal escape sequence is the longest sequence of characters that can constitute the escape sequence. octal escapes are 1-3 characters, hex ones are 1-infinity ("hexadecimal-escape-sequence" in the syntax listing is recursive)
Comment #1 by dlang-bot — 2022-04-20T06:28:37Z
@WalterBright created dlang/dmd pull request #14017 "fix Issue 23031 - importC: hex character escapes should be variable l…" fixing this issue: - fix Issue 23031 - importC: hex character escapes should be variable length https://github.com/dlang/dmd/pull/14017
Comment #2 by dlang-bot — 2022-04-20T08:29:44Z
dlang/dmd pull request #14017 "fix Issue 23031 - importC: hex character escapes should be variable l…" was merged into master: - 476dcb38a388e531522ecbe713bc905f184a7e85 by Walter Bright: fix Issue 23031 - importC: hex character escapes should be variable length https://github.com/dlang/dmd/pull/14017