Comments (5)
I suspect the same problem could occur with function parameter references, though an example would have to be very complicated.
from cxx-abi.
The original mangled name is invalid. The right way to refer to Rangitoto
in the substitution would be S1_
, not S2_
, which is what compilers produce for examples that mangle that way, and the modified mangling is demangled the same way by libstdc++'s demangler and libc++abi's demangler.
We can reach cases that demonstrate the problem in question with an example like this:
template<typename T> void ignore(T*);
struct Rangitoto {};
struct Foobar {};
template<typename T, void(*)(Foobar*)> void hello(T*) {}
template void hello<Rangitoto, ignore<Foobar> >(Rangitoto*);
Everyone mangles this as _Z5helloI9RangitotoXadL_Z6ignoreI6FoobarEvPT_EEEvS4_
. However, libstdc++ demangles that to the source declaration, libc++abi demangles it to a function taking Foobar*
instead.
In summary, Clang, GCC, ICC, and the libstdc++ demangler all agree that when a S<n>_
refers to a T<n>_
, the T<n>_
is interpreted in the context where the S<n>_
appears, not in its original context; only the libc++abi demangler disagrees. Presumably that is the rule we should use, then. However, see the problem under discussion in #106, which points out that this kind of situation is hard to demangle in general.
from cxx-abi.
In summary, Clang, GCC, ICC, and the libstdc++ demangler all agree that when a
S<n>_
refers to aT<n>_
, theT<n>_
is interpreted in the context where the S_ appears, not in its original context; .. Presumably that is the rule we should use
That's great news. I hope you're able to update the spec text to clarify that.
from cxx-abi.
For the record, the real-life issue that triggered this bug report was:
gimli-rs/cpp_demangle#165 (comment)
In particular this symbol was generated by (some circa-2018 version of) clang++:
_ZN7mozilla6detail12ListenerImplINS_14AbstractThreadEZNS_20MediaEventSourceImplILNS_14ListenerPolicyE0EJNS_13TimedMetadataEEE15ConnectInternalIS2_NS_12MediaDecoderEMS8_FvOS5_EEENS_8EnableIfIXsr8TakeArgsIT1_EE5valueENS_18MediaEventListenerEE4TypeEPT_PT0_SD_EUlS9_E_JS5_EE17ApplyWithArgsImplISL_EENSC_IXsr8TakeArgsISH_EE5valueEvE4TypeERKSH_S9_
llvm-cxxfilt
11.0 demangles it to
mozilla::EnableIf<TakeArgs<mozilla::AbstractThread>::value, void>::Type mozilla::detail::ListenerImpl<mozilla::AbstractThread, mozilla::EnableIf<TakeArgs<void (mozilla::MediaDecoder::*)(mozilla::TimedMetadata&&)>::value, mozilla::MediaEventListener>::Type mozilla::MediaEventSourceImpl<(mozilla::ListenerPolicy)0, mozilla::TimedMetadata>::ConnectInternal<mozilla::AbstractThread, mozilla::MediaDecoder, void (mozilla::MediaDecoder::*)(mozilla::TimedMetadata&&)>(mozilla::AbstractThread*, mozilla::MediaDecoder*, void (mozilla::MediaDecoder::*)(mozilla::TimedMetadata&&))::'lambda'(mozilla::TimedMetadata&&), mozilla::TimedMetadata>::ApplyWithArgsImpl<mozilla::EnableIf<TakeArgs<void (mozilla::MediaDecoder::*)(mozilla::TimedMetadata&&)>::value, mozilla::MediaEventListener>::Type mozilla::MediaEventSourceImpl<(mozilla::ListenerPolicy)0, mozilla::TimedMetadata>::ConnectInternal<mozilla::AbstractThread, mozilla::MediaDecoder, void (mozilla::MediaDecoder::*)(mozilla::TimedMetadata&&)>(mozilla::AbstractThread*, mozilla::MediaDecoder*, void (mozilla::MediaDecoder::*)(mozilla::TimedMetadata&&))::'lambda'(mozilla::TimedMetadata&&)>(mozilla::AbstractThread const&, mozilla::TimedMetadata&&)
while c++filt
2.35 fails to demangle it.
Perhaps that version of clang++ mangled the symbol incorrectly. I would have tried to come up with a minimal C++ testcase but I'm not adept at taking a symbol like that and reverse-engineering some minimal C++ code that produces it...
from cxx-abi.
libc++abi demangles it to a function taking
Foobar*
instead.
I hope someone fixes this. Once that's fixed, it'll be interesting to see if that changes llvm-cxxfilt
's demangling of the Mozilla symbol above.
from cxx-abi.
Related Issues (20)
- "Deducing this" mangling HOT 14
- Should std::rethrow_exception be covered by the EH ABI? HOT 2
- Emergency EH buffer is overspecified HOT 6
- Where is the most recent ABI document? HOT 1
- Add `[[trivial_abi]]` attribute
- Lambda POD for the purposes of layout? HOT 2
- Mangling the name of an externally visible lambda in a static data member of a class HOT 1
- Proposal: Include an optional specification for mangling names that reference anonymous symbols HOT 4
- Is it possible to form a pointer-to-data-member with offset -1 using explicit derived-to-base conversions without UB? HOT 3
- unnecessary `E`s after <expression> and mangling collisions between <expression> and <number> HOT 1
- need mangling for lambdas appearing in unevaluated operands within a class body HOT 3
- What does "forbidding the use of function templates" mean? HOT 2
- [C++20] [Modules] Do we need the concept of `key function` for class defined in module purview? HOT 25
- Missing HTML encoding in 2.3.1 Data Member Pointers HOT 2
- Proposal: document or somehow notice __cxa_init_primary_exception HOT 3
- Mangling for C++ pack indexing HOT 1
- Function and function pointer types with vendor calling conventions HOT 2
- Ambiguity in mangling grammar around type qualifiers HOT 8
- Question about section 2.9.4 HOT 4
- Questions About Non-POD Types Data Layout HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cxx-abi.