[Issue 21200] const(Class) should be C++ mangled as Class const *

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sun Jun 20 19:33:04 UTC 2021


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

moonlightsentinel at disroot.org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |moonlightsentinel at disroot.o
                   |                            |rg

--- Comment #2 from moonlightsentinel at disroot.org ---
That would allow external code to silently break the type system as soon as
references are involved:

==========================================
// D

extern(C++) class C {}

extern(C++) void foo(ref const C);

void main()
{
    static immutable C c = new C();
    foo(c);
}

==========================================
// C++

class C;

void foo(const C*& c)
{
    c = nullptr; // <= boom
}

==========================================

(Allthough class + ref should be rare outside of generic code)

--


More information about the Digitalmars-d-bugs mailing list