Thread overview | ||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
September 23, 2018 [Issue 19260] extern(C++) `T* const` mangling | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=19260 Manu <turkeyman@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Keywords| |C++, industry -- |
September 23, 2018 [Issue 19260] extern(C++) `T* const` mangling | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=19260 kinke@gmx.net changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |kinke@gmx.net --- Comment #1 from kinke@gmx.net --- Patching the mangle at compile-time like this (MSVC only) might work: extern(C++) template deallocate(T) { void _deallocate(T* ptr, size_t count); private extern(D) string getMangle() { import std.array; return _deallocate.mangleof.replace("PEAU", "QEAU"); } pragma(mangle, getMangle()) void deallocate(T* ptr, size_t count); } D: https://run.dlang.io/is/q4kF2e C++: https://godbolt.org/z/GpXfqV -- |
September 29, 2018 [Issue 19260] extern(C++) `T* const` mangling | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=19260 --- Comment #2 from Manu <turkeyman@gmail.com> --- I have used that hack to move forward... but it's not a reasonable solution. -- |
September 29, 2018 [Issue 19260] extern(C++) `T* const` mangling | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=19260 --- Comment #3 from kinke@gmx.net --- I don't think there's a need for a proper solution for this on the D side: 1) `T* const` is rare in my experience. 2) This `const` affecting the C++ mangle is a big mistake IMO. The caller can't care less about it, it's just an implementation detail of the callee (not gonna mutate the param, i.e., my private pointer copy) leaking to the outside world and causing issues like this. -- |
September 29, 2018 [Issue 19260] extern(C++) `T* const` mangling | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=19260 --- Comment #4 from Manu <turkeyman@gmail.com> --- But it's impossible to link. That's really important... -- |
September 29, 2018 [Issue 19260] extern(C++) `T* const` mangling | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=19260 --- Comment #5 from kinke@gmx.net --- Well, as shown, D is flexible enough to overcome crappy situations like this, albeit in cumbersome ways. Just saying that I don't think it's worthwhile to come up, implement and document solutions to exotic problems like this, which could also be tackled on the C++ side. I take it you cannot simply add another C++ template, as that one probably doesn't get instantiated on the C++ side, and aren't willing to hack the STL either. Btw, cppreference says the signature is `T*` [https://en.cppreference.com/w/cpp/memory/allocator/deallocate], so does MS have to go its own route once again? ;) -- |
September 29, 2018 [Issue 19260] extern(C++) `T* const` mangling | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=19260 --- Comment #6 from Manu <turkeyman@gmail.com> --- Of course! This is MS after all! This is not the first time this class of issue has emerged however, but in this case, I'm powerless to make any change to help... -- |
October 22, 2018 [Issue 19260] extern(C++) `T* const` mangling | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=19260 Mathias LANG <pro.mathias.lang@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |pro.mathias.lang@gmail.com --- Comment #7 from Mathias LANG <pro.mathias.lang@gmail.com> --- I strongly agree with Kinke here and think we should not pursue mangling head const, as it's already possible to do it with a small hack (and it's a one-time cost). -- |
October 23, 2018 [Issue 19260] extern(C++) `T* const` mangling | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=19260 --- Comment #8 from Manu <turkeyman@gmail.com> --- We could give the argument a @MangleHeadConst attribute or something that the mangler recognises...? -- |
October 23, 2018 [Issue 19260] extern(C++) `T* const` mangling | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=19260 --- Comment #9 from kinke@gmx.net --- -1, as that won't work for `T *const *`, i.e., only for a very specific case, so I find a dedicated UDA + compiler complexity a total overkill. -- |
Copyright © 1999-2021 by the D Language Foundation