-
Notifications
You must be signed in to change notification settings - Fork 12k
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
Stack overflow in clang-query 17, ItaniumMangle.cpp #86240
Comments
Could you please try 18 or |
@llvm/issue-subscribers-clang-frontend Author: Konstantin Romanov (ksromanov)
On our machines (Linux) clang-tidy (llvm 17) crashes when processing
template <class RET> struct Context {
using Ptr = Context<RET> *;
};
template <typename Callable> void scheduleCoro(Callable &&coro_function) {
[coro_function{coro_function}](
typename Context<decltype(coro_function())>::Ptr ctx) -> int {
return 0;
};
} To reproduce
with stack dump
|
|
Does reproduce on both 18 and main branches. |
If I understand it right, the root cause is inside Itanium C++ ABI — the mangling standard does not support recursive types. In Hindley-Milner type system they use type variables, so it is possible to express the type that takes itself as an argument: type 'a funct =
Run of (('a funct) option -> unit) here In the snippet that we are interested in, they have:
It is just a regular tree structure, without any type variables. Also // FIXME: GCC does not appear to mangle the template arguments when
// the template in question is a dependent template name. Should we
// emulate that badness? llvm-project/clang/lib/AST/ItaniumMangle.cpp Line 1299 in a3efc53
Perhaps it is not badness, it is just a way to avoid infinite recursion in the absence of the support for recursive types in Itanium C++ ABI. Of course, it is not the best choice, and perhaps someone can come up with a better proposal. |
@ksromanov and I uncovered some more details: This code compiles with clang trunk
But, when changing the line with
Meanwhile, GCC rejects this code with https://godbolt.org/z/zW4n445cM Once instantiating In rejecting the
|
git bisect shows 93d7002 is what broke things (well, it fixed other things too). Before this commit, clang compiles https://godbolt.org/z/zW4n445cM without stack overflowing. Reading P2036R3, it looks like the code from the original post should be rejected since cc @cor3ntin |
On our machines (Linux) clang-tidy (llvm 17) crashes when processing
To reproduce
with stack dump
The text was updated successfully, but these errors were encountered: