| Summary: | ICE/segmentation fault in lambda function | ||
|---|---|---|---|
| Product: | gcc | Reporter: | Tobias Schuele <t.schuele> |
| Component: | c++ | Assignee: | Not yet assigned to anyone <unassigned> |
| Status: | RESOLVED DUPLICATE | ||
| Severity: | normal | Keywords: | c++-lambda |
| Priority: | P3 | ||
| Version: | 4.7.0 | ||
| Target Milestone: | --- | ||
| Host: | Target: | ||
| Build: | Known to work: | ||
| Known to fail: | Last reconfirmed: | 2012-03-20 00:00:00 | |
| Bug Depends on: | |||
| Bug Blocks: | 54367 | ||
Confirmed. We should figure out a reduced testcase not including anything (note: the internals of <atomic> are completely different in 4.7 vs 4.6) The crash happens in lvalue_kind: an INDIRECT_REF with no TREE_TYPE. Here is a testcase not including anything:
template <typename T>
struct foo {
operator T() {
return T();
}
};
template<typename T>
struct test {
foo<int> x;
void bar() {
auto f = [this] {return x != 0;};
}
};
As in the above testcase, the ICE disappears if implicit type conversion is avoided:
auto f = [this] {return (int)x != 0;};
Thanks! |
Hi, the following piece of code causes an ICE (segmentation fault) when compiled with gcc-4.7.0-RC-20120302 (no problem with gcc 4.6.3): #include <atomic> template<typename T> struct test { std::atomic<int> x; void foo() { auto cond = [this] {return x != 0;}; } }; It works if the value of x is loaded explicitly: auto cond = [this] {return x.load() != 0;};