Bug 22935 – importC: offsetof with array element gives 'dereference of invalid pointer'

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2022-03-25T15:36:16Z
Last change time
2022-03-31T08:23:22Z
Keywords
ImportC, pull, rejects-valid
Assigned to
No Owner
Creator
duser
See also
https://issues.dlang.org/show_bug.cgi?id=22929

Comments

Comment #0 by duser — 2022-03-25T15:36:16Z
using the offsetof macro from importc.h: typedef unsigned long size_t; struct S { char text[4]; }; //int tmp = __builtin_offsetof(struct S, text[0]); int tmp = ((size_t)((char *)&((struct S *)0)->text[0] - (char *)0)); Error: dereference of invalid pointer `cast(S*)0LU` the fix for issue 22809 didn't affect this
Comment #1 by dlang-bot — 2022-03-30T08:03:25Z
@WalterBright created dlang/dmd pull request #13925 "fix Issue 22935 - importC: offsetof with array element gives 'derefer…" fixing this issue: - fix Issue 22935 - importC: offsetof with array element gives 'dereference of invalid pointer' https://github.com/dlang/dmd/pull/13925
Comment #2 by dlang-bot — 2022-03-31T08:23:22Z
dlang/dmd pull request #13925 "fix Issue 22935 - importC: offsetof with array element gives 'derefer…" was merged into master: - 10a7ee5bd5e8f4572ae9864dbba7ea6ab733edf4 by Walter Bright: fix Issue 22935 - importC: offsetof with array element gives 'dereference of invalid pointer' https://github.com/dlang/dmd/pull/13925