Bug 52619 - ICE/segmentation fault in lambda function
Summary: ICE/segmentation fault in lambda function
Status: RESOLVED DUPLICATE of bug 54122
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 4.7.0
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords: c++-lambda
Depends on:
Blocks: lambdas
  Show dependency treegraph
 
Reported: 2012-03-19 15:23 UTC by Tobias Schuele
Modified: 2022-03-11 00:32 UTC (History)
0 users

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2012-03-20 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Tobias Schuele 2012-03-19 15:23:13 UTC
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;};
Comment 1 Paolo Carlini 2012-03-20 10:54:16 UTC
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)
Comment 2 Paolo Carlini 2012-03-20 11:03:00 UTC
The crash happens in lvalue_kind: an INDIRECT_REF with no TREE_TYPE.
Comment 3 Tobias Schuele 2012-03-22 15:36:42 UTC
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;};
Comment 4 Paolo Carlini 2012-03-22 16:30:02 UTC
Thanks!
Comment 5 Paolo Carlini 2012-10-04 01:31:22 UTC
Probably Dup of PR54403.
Comment 6 Paolo Carlini 2013-02-06 10:12:00 UTC
Fixed by the patch which fixed PR54122.

*** This bug has been marked as a duplicate of bug 54122 ***