www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 22620] New: mangleof sometimes missing C++ namespace or


          Issue ID: 22620
           Summary: mangleof sometimes missing C++ namespace or
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Windows
            Status: NEW
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: tim.dlang t-online.de


class Child : Parent

extern(C++, "Namespace") extern(C++, class) struct Struct

class Parent
    //pragma(msg, __traits(getCppNamespaces, Struct));
    private static void func(Struct*);
    pragma(msg, "     MangleInClass: " ~ func.mangleof);
pragma(msg, "MangleOutsideClass: " ~ Parent.func.mangleof);


The code above prints the mangling of the same member function twice. For
Windows 64 bit the output is:
     MangleInClass: ?func Parent  CAXPEAUStruct   Z
MangleOutsideClass: ?func Parent  CAXPEAVStruct Namespace   Z
For Linux the output is:
     MangleInClass: _ZN6Parent4funcEP6Struct
MangleOutsideClass: _ZN6Parent4funcEPN9Namespace6StructE

Normally it should print the same mangling inside and outside the class, but
actually the mangling is incomplete inside the class. On both platforms it
misses the namespace and on Windows also ignores extern(C++, class). The
mangling printed outside the class is correct.

If trait getCppNamespaces is used inside the class for Struct, then the
mangling  will later also be printed correctly inside the class.

Dec 22 2021