Bug 55853 - [C++11] ICE calling member function of templated class in lambda
Summary: [C++11] ICE calling member function of templated class in lambda
Status: RESOLVED DUPLICATE of bug 53137
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 4.7.2
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-01-03 01:12 UTC by Kyle Konrad
Modified: 2013-01-03 16:21 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments
preprocessed source (38.93 KB, application/octet-stream)
2013-01-03 01:12 UTC, Kyle Konrad
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Kyle Konrad 2013-01-03 01:12:03 UTC
Created attachment 29075 [details]
preprocessed source

This appears to be similar but not identical to http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54604.

Repro case:

#include <map>
#include <functional>

using namespace std;

struct tData {
  double a;
};

template<class DataType>
class MapWrap {
public:

  void Insert(const int& p, const DataType& data) {
    m_[p] = data;
  }

  function<void(const DataType&)> CreateInserter(function<int(const DataType&)> data_to_int) {
    return [this, data_to_int](const DataType& data) { Insert(data_to_int(data), data); };
  }

private:
  map<int, DataType> m_;
};

int main(int argc, char **argv) {
  MapWrap<tData> m;
  auto fn = m.CreateInserter([](const tData& d) { return static_cast<int>(d.a); });
  fn({12});
}
Comment 1 Kyle Konrad 2013-01-03 01:13:26 UTC
I forgot to mention that adding "this->" to the Insert() call causes compilation to succeed.
Comment 2 Kyle Konrad 2013-01-03 01:15:56 UTC
Version information:

$ g++ -v
Using built-in specs.
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/4.7/lto-wrapper
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Debian 4.7.2-4' --with-bugurl=file:///usr/share/doc/gcc-4.7/README.Bugs --enable-languages=c,c++,go,fortran,objc,obj-c++ --prefix=/usr --program-suffix=-4.7 --enable-shared --enable-linker-build-id --with-system-zlib --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --with-gxx-include-dir=/usr/include/c++/4.7 --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --enable-gnu-unique-object --enable-plugin --enable-objc-gc --with-arch-32=i586 --with-tune=generic --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu
Thread model: posix
gcc version 4.7.2 (Debian 4.7.2-4)
Comment 3 Paolo Carlini 2013-01-03 16:21:31 UTC
Dup.

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