-
Notifications
You must be signed in to change notification settings - Fork 12.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
std::enable_if mangling different in clang >= 18 compared to clang <= 17 or gcc #85656
Comments
@philnik777 did a bunch of refactoring touching 76a2472 [libc++] Refactor more __enable_ifs to the canonical style (#81457) Not sure if these were supposed to change any mangling, though. |
Mmmm I should have written it in my first message, the STL used is libstdc++, not libc++. More precisely in my case, the one of gcc 13 (taken from a rather fresh commit from the releases/gcc-13 branch). Compiler explorer also uses libstdc++ by default. |
This is caused by a fix in the Itanium mangling. You can get the old mangling with |
Ok thanks. So I opened this bug on gcc side to adopt the same mangling change if indeed the historical one was invalid: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114383 |
@llvm/issue-subscribers-clang-frontend Author: Romain Geissler @ Amadeus (Romain-Geissler-1A)
Hi,
While migrating to clang 18, we hit a name mangling difference compared to clang 17 (or gcc). The following snippet:
eventually leads to clang 18 mangle the call to SomeFunction as Is this change with clang 18 expected ? |
It would be useful to point to the change that was done so the GCC folks can make sure it is done correctly there. |
4b163e3 is the patch that changed it. I've read the commit message again, and it may not actually be intended given that the patch claims that only new constructs are affected, which I don't think is the case here. CC @zygoloid @AaronBallman @erichkeane |
It's intentional that the mangling here changed, and necessary for conformance. Note that this is valid: template <typename T, typename std::enable_if<SomeCondition<T>::value, int>::type = 0> void SomeFunction(const T&) {}
template <typename T, typename std::enable_if<OtherSomeCondition<T>::value, int>::type = 0> void SomeFunction(const T&) {} ... and declares two different function templates. Without this change, they would mangle the same. It's also valid for one of those templates to be declared in one translation unit and the other to be declared in a different translation unit, resulting in both templates actually being used with the same T in the same program.
See: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100825 |
Also, apologies for the incomplete commit message. There wasn't much I could do about that once I noticed, but I updated the release notes here: aaa79a5 |
Indirectly related to this, should the demangler show the actual condition to better spot which symbol we are talking about ? Because right now |
Hi,
While migrating to clang 18, we hit a name mangling difference compared to clang 17 (or gcc).
The following snippet:
eventually leads to clang 18 mangle the call to SomeFunction as
_Z12SomeFunctionIiTnNSt9enable_ifIXsr13SomeConditionIT_EE5valueEiE4typeELi0EEvRKS1_
(see Compiler explorer: https://godbolt.org/z/Khv93qxvf) while clang 17 does mangle it as_Z12SomeFunctionIiLi0EEvRKT_
(Compiler explorer: https://godbolt.org/z/WKeanb15P), and gcc as well (Compiler explorer: https://godbolt.org/z/1eqGKdnzY).Is this change with clang 18 expected ?
The text was updated successfully, but these errors were encountered: