llvm / llvm-project

The LLVM Project is a collection of modular and reusable compiler and toolchain technologies.
http://llvm.org
Other
28.02k stars 11.57k forks source link

Type deduction and capture in lambda fails if type is defined far away (?) from the point of deduction #44883

Open 0845b516-6c75-4cca-b5e1-33ea8292f6b9 opened 4 years ago

0845b516-6c75-4cca-b5e1-33ea8292f6b9 commented 4 years ago
Bugzilla Link 45538
Version 10.0
OS Linux
Attachments minimal example and the install script for LLVM
CC @dwblaikie

Extended Description

The problem presented itself while using the boost unit test framework. It seems like that it is both a type deduction and a lambda capture issue, which only happens if the type deduction has to be carried out through many layers of indirection. Therefore, unfortunately, I couldn't eliminate the boost unit test framework from the minimal example.

The error is:

test_true_minimal.cpp:20:30: error: variable 'j' cannot be implicitly captured in a lambda with no capture-default specified
      g([=](const test_class<j, 3> item) {});

I am using the newest commit from the release/10.x branch (edbe962459da6e3b7b4168118f93a77847b54e02) I built clang locally, with the build script install_llvm.sh (attached) inside an archlinux singularity container. boost has been installed from the arch repos, version 1.72.

I read the guide for regarding bug reports, but I am not sure in this particular case which files are relevant. Please let me know if you need any further input.

The original discussion on GitHub might also be useful: https://github.com/illuhad/hipSYCL/issues/231

0845b516-6c75-4cca-b5e1-33ea8292f6b9 commented 4 years ago

PS: The provided minimal example compiles with both clang 9.0.1 and gcc 9.2.1 as well.