https://issues.dlang.org/show_bug.cgi?id=22935

          Issue ID: 22935
           Summary: importC: offsetof with array element gives
                    'dereference of invalid pointer'
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Keywords: ImportC, rejects-valid
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: [email protected]
          Reporter: [email protected]
                CC: [email protected]

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

--

Reply via email to