www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 22935] New: importC: offsetof with array element gives


          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: nobody puremagic.com
          Reporter: duser neet.fi
                CC: duser neet.fi

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

Mar 25 2022