Bug 22756 – ImportC: no __builtin_offsetof

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2022-02-10T10:47:09Z
Last change time
2022-02-17T13:16:48Z
Keywords
ImportC, pull
Assigned to
No Owner
Creator
dave287091

Comments

Comment #0 by dave287091 — 2022-02-10T10:47:09Z
C11 defines a standard macro `offsetof` (which is defined in 7.19 in the definition of what is in the <stddef.h> header). Clang implements this with a compiler intrinsic `__builtin_offsetof`. I can’t find a clang reference, but it just does what the macro would do. The following C code: // off.c #include <stddef.h> struct Foo { int x; }; int y = offsetof(struct Foo, x) Expands to: // off.i struct Foo { int x; }; int y = __builtin_offsetof(struct Foo, x); which dmd rejects, as it can’t handle the __builtin_offsetof. The above is the simplest case, the following is also allowed: struct Foo { struct { int x; } y; }; int y = __builtin_offsetof(struct Foo, y.x);
Comment #1 by dlang-bot — 2022-02-11T09:03:18Z
@WalterBright updated dlang/druntime pull request #3736 "fix Issue 22756 - ImportC: no __builtin_offsetof" fixing this issue: - fix Issue 22756 - ImportC: no __builtin_offsetof https://github.com/dlang/druntime/pull/3736
Comment #2 by dlang-bot — 2022-02-11T10:14:26Z
dlang/druntime pull request #3736 "fix Issue 22756 - ImportC: no __builtin_offsetof" was merged into master: - cd85cb0bbf4674d774e88161cdbbd70422aaacbd by Walter Bright: fix Issue 22756 - ImportC: no __builtin_offsetof https://github.com/dlang/druntime/pull/3736
Comment #3 by dave287091 — 2022-02-11T18:33:18Z
The above PR defines a “__builtin_offset”, not a “__builtin_offsetof”.
Comment #4 by dlang-bot — 2022-02-12T07:23:03Z
@WalterBright created dlang/druntime pull request #3739 "fix Issue 22756 - ImportC: no __builtin_offsetof" fixing this issue: - fix Issue 22756 - ImportC: no __builtin_offsetof https://github.com/dlang/druntime/pull/3739
Comment #5 by dlang-bot — 2022-02-17T13:16:48Z
dlang/druntime pull request #3739 "fix Issue 22756 - ImportC: no __builtin_offsetof" was merged into master: - b917bc143c58485ade6dbad5ca0dd6e8efd74bf5 by Walter Bright: fix Issue 22756 - ImportC: no __builtin_offsetof https://github.com/dlang/druntime/pull/3739