Bug 22899 – importC: extra parentheses in sizeof should give error with typedef types

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2022-03-18T10:56:40Z
Last change time
2022-03-22T07:03:05Z
Keywords
accepts-invalid, ImportC, pull
Assigned to
No Owner
Creator
duser

Comments

Comment #0 by duser — 2022-03-18T10:56:40Z
typedef int mytype_t; void fn() { int x; x = sizeof( (mytype_t) ); // no error x = sizeof( (int) ); // ok: Error: expression expected, not `int` } autoconf configure scripts rely on this being an error when determining if a type is supported: https://github.com/autotools-mirror/autoconf/blob/64df9b4/lib/autoconf/types.m4#L65
Comment #1 by bugzilla — 2022-03-19T07:43:16Z
The salient bit of the link is: sizeof ((TYPE)); # This evokes a syntax error when TYPE is a type, but succeeds if TYPE # is actually a variable.
Comment #2 by bugzilla — 2022-03-19T08:20:11Z
Fixing this is blocked by https://github.com/dlang/dmd/pull/13831
Comment #3 by dlang-bot — 2022-03-21T05:56:43Z
@WalterBright created dlang/dmd pull request #13851 "fix Issue 22899 - importC: extra parentheses in sizeof should give er…" fixing this issue: - fix Issue 22899 - importC: extra parentheses in sizeof should give error with typedef types https://github.com/dlang/dmd/pull/13851
Comment #4 by dlang-bot — 2022-03-22T07:03:05Z
dlang/dmd pull request #13851 "fix Issue 22899 - importC: extra parentheses in sizeof should give er…" was merged into master: - 0117a8df8f9e77802d256626fa859101c61549d3 by Walter Bright: fix Issue 22899 - importC: extra parentheses in sizeof should give error with typedef types https://github.com/dlang/dmd/pull/13851