https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85646
Bug ID: 85646 Summary: Incorrect lambda visibility with -fvisibility=hidden Product: gcc Version: 8.1.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: duarte at scylladb dot com Target Milestone: --- Consider the following program: template<typename T> void foo() { struct inner { inner() { (void)([this] { }); } }; } int main() { foo<int>(); } Compiles fine on 6.3, but fails on 7.1, 7.2, 7.3, 8.0.1 and 8.1, with <source>:5:13: error: 'foo()::inner::inner() [with T = int]::<lambda()>' declared with greater visibility than the type of its field 'foo()::inner::inner() [with T = int]::<lambda()>::<this capture>' [-Werror=attributes] Godbolt: https://godbolt.org/g/aGaVgd