www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - =?UTF-8?B?W0lzc3VlIDIyNDMyXSBOZXc6IEltcG9ydEM6IGNhc3RpbmcgbWVt?=

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

          Issue ID: 22432
           Summary: ImportC: casting member of parenthesized struct to
                    typedef’d type is parsed incorrectly
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: major
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: dave287091 gmail.com

The following c program fails to compile:

// test.c
struct Foo {
    int x;
};
typedef int int32_t;

void foo(void){
    struct Foo f = {1};
    int x0 = ((int)(f).x);
    int x1 = (int)(f).x;
    int32_t x2 = (int32_t)(f).x; // Error
    int32_t x3 = ((int32_t)(f).x); // Error
    int32_t x4 = (int32_t)f.x;
}

// test.c(11): Error: `=`, `;` or `,` expected
// test.c(12): Error: found `.` when expecting `)`
// test.c(12): Error: missing comma
// test.c(12): Error: `=`, `;` or `,` expected

Works with builtin types, fails with typedef’d types.

--
Oct 22 2021