-
-
Notifications
You must be signed in to change notification settings - Fork 245
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
ranged for-loop inside lambda crashes #238
Comments
Hello @hessbe, thank you! Nice finding. Here we have a range-based for-loop in an unevaluated context. Hence, not all the necessary information is present. My fix would be to show the range-based for-loop as it is in this cases. What do you think? Andreas |
On a second thought, it is easier to transform it. This is more consistent and requires less special cases. Your initial example would then look like this: void f()
{
class __lambda_1_26
{
public:
template<class type_parameter_0_0>
inline /*constexpr */ auto operator()(type_parameter_0_0 container) const
{
{
auto && __range1 = container;
for(; ; )
{
auto test;
}
}
}
private:
template<class type_parameter_0_0>
static inline auto __invoke(type_parameter_0_0 container)
{
{
auto && __range1 = container;
for(; ; )
{
auto test;
}
}
}
};
__lambda_1_26 lambda = __lambda_1_26{};
} Andreas |
In my opinion that's good enough as long as the instantiation is correct. Or how difficult is it to show everything with auto? Like this: |
Hello @hessbe, difficult as at this point it is unknown. It can also be that Andreas |
Hi Andrea, I'm fully content with your proposed solution. I was preparing some examples for internal training and this crash popped up so I wanted to make sure you know about it. There was also a template instantiation In the example so the full solution would be shown there and that's all I wanted to show the team. Ben |
… context. In case of a range-based for-loop in something like a template the types of range statements are not known. In this case just omit them as they are not there.
Hello @hessbe, excellent, and sorry for the trouble before your training. A fix is on its way. Andreas |
… context. In case of a range-based for-loop in something like a template the types of range statements are not known. In this case just omit them as they are not there.
… context. In case of a range-based for-loop in something like a template the types of range statements are not known. In this case just omit them as they are not there.
Fixed #238: Prevent crash of a range-based for-loop in an unevaluated context.
this example crashes the conversion:
void f() { auto lambda = [](auto container) { for(auto test : container) { } }; }
also with a template instantiation:
`#include
void f() {
auto lambda = [](auto container) {
for(auto test : container) { }
};
std::vector vec{1,2,3,4};
lambda(vec);
}`
[0x13449ff] ... [0x4055aa] Segmentation fault (core dumped)
The text was updated successfully, but these errors were encountered: