On Saturday, September 7, 2019 8:53:54 AM MDT Max Samukha via Digitalmars-d- learn wrote: > extern(C++, "ns1") { > extern(C++, ns2) { > extern(C++, "ns3") { > extern(C++, ns4) { > void foo(); > } > } > } > } > > pragma(msg, foo.mangleof); // _ZN3ns23ns43ns13ns33fooEv > > That produces 'ns2::ns4::ns1::ns3::foo' path instead of the > intuitively expected 'ns1::ns2::ns3::ns4::foo'. The identifier > namespaces are grouped before the string ones. Bug or feature?
Given that the string version of extern(C++) is supposed to only affect mangling, whereas the other version does some other weird stuff, I'm not sure that you can really expect something sane if you try to mix them. That being said, unless the language disallows mixing them, the compiler should be doing something at least semi-sane. Either way, I don't see how having the result be anything other than ns1:ns2:ns3:ns4 is defensible. The type of weirdness that I would expect would resolve around the kind of issues that led to the string version being added in the first place (e.g. having to put the entire namespace in a single module). I'd suggest that you report it as a bug. It wouldn't surprise me if dmd doesn't even have any tests that try to mix the two types of extern(C++), since that really wasn't an intended use case. If anything, I expect that the hope was that the non-string version would eventually be deprecated, though I wouldn't bet on that actually happening. - Jonathan M Davis