-
Notifications
You must be signed in to change notification settings - Fork 12.6k
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
Structured binding packs ICE #125103
Comments
@llvm/issue-subscribers-clang-frontend Author: LEE KYOUNGHEON (stripe2933)
After some experiments using recently merged structured binding packs PR, I found this ICE. [Compiler Explorer](https://godbolt.org/z/9dMa74sEv)
#include <format>
#include <print>
#include <type_traits>
#define FWD(...) static_cast<decltype(__VA_ARGS__)&&>(__VA_ARGS__)
template <typename T> requires std::is_aggregate_v<std::remove_cvref_t<T>>
[[nodiscard]] constexpr auto as_tuple(T &&v) {
auto &&[...xs] = FWD(v);
return std::forward_as_tuple(FWD(xs)...);
}
template <typename T, typename CharT>
requires std::is_aggregate_v<T>
struct std::formatter<T, CharT> : formatter<decltype(as_tuple(std::declval<T>())), CharT> {
constexpr auto format(const T &v, std::format_context &ctx) const {
return formatter<decltype(as_tuple(std::declval<T>()))>::format(as_tuple(v), ctx);
}
};
struct Person {
std::string name;
int age;
};
int main() {
std::println("{}", Person { .name = "lee kyoungheon", .age = 23 });
}
When I changed |
@ricejasonf @zyn0217 I haven't figured out yet if it's a lambda bug or pack bug but I figure that might be of interest to both of you |
I can look at this possibly this weekend. The stack trace looks familiar like when the BindingDecl's Decomp was not set. |
Just ran into this as well; this crashes in seemingly the same place (https://godbolt.org/z/GqEjMKb8c): struct S {
int a, b, c;
};
auto X = [] <typename = void> () {
auto [...pack] = S{};
}; |
Also, here’s a link to @stripe2933’s example with assertions enabled; it seems to be the same assertion: https://godbolt.org/z/rxx19zdxf |
After some experiments using recently merged structured binding packs PR, I found this ICE. Compiler Explorer
When I changed
decltype(as_tuple(std::declval<T>()))
tostd::tuple<const std::string&&, const int&&>
, it compiles well.The text was updated successfully, but these errors were encountered: