[Issue 17822] [betterC] Do not emit reference to TypeInfo_Class for C++ or COM classes

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sat Jun 11 17:03:29 UTC 2022


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

Richard Cattermole <alphaglosined at gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |alphaglosined at gmail.com
         Resolution|---                         |WORKSFORME

--- Comment #2 from Richard Cattermole <alphaglosined at gmail.com> ---
The definition by itself does not error.

But it is possible to make it error with a ClassZ linker error if you use new.

Works:

```d
extern (C++) class CC {
    int a;
}

extern(C) void main() {
    __gshared CC cc = new CC;
    cc.a = 4;
}
```

And so does:

```d
extern (C++) class CC {
    int a;
}

extern(C) void main() {
    scope CC cc = new CC;
    cc.a = 4;
}
```

Doesn't:

```d
extern (C++) class CC {
    int a;
}

extern(C) void main() {
    CC cc = new CC;
    cc.a = 4;
}
```

With:

```
./onlineapp.d:6: error: undefined reference to '_D9onlineapp2CC7__ClassZ'
./onlineapp.d:6: error: undefined reference to '_d_newclass'
collect2: error: ld returned 1 exit status
```

I'll close this as WORKSFORME, because it seems to be working correctly.

--


More information about the Digitalmars-d-bugs mailing list