[llvm-bugs] [Bug 47564] New: auto trick for recursive lambdas works with gcc, but not always with clang

via llvm-bugs llvm-bugs at lists.llvm.org
Thu Sep 17 09:38:20 PDT 2020


https://bugs.llvm.org/show_bug.cgi?id=47564

            Bug ID: 47564
           Summary: auto trick for recursive lambdas works with gcc, but
                    not always with clang
           Product: clang
           Version: 10.0
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: C++14
          Assignee: unassignedclangbugs at nondot.org
          Reporter: janezz55 at gmail.com
                CC: blitzrakete at gmail.com, erik.pilkington at gmail.com,
                    llvm-bugs at lists.llvm.org, richard-llvm at metafoo.co.uk

Created attachment 23976
  --> https://bugs.llvm.org/attachment.cgi?id=23976&action=edit
example file illustrating the bug

Take this example:

auto const f([](int const i, auto ...) noexcept -> int
  {
    return i == 1 ? 1 : i * operator()(i - 1);
  }
);

under gcc 10.2.0 the lambda will compile and work as expected - and will do so
every time an auto argument is used, but clang 10.0.1 reports:

t.cpp:6:31: error: use of undeclared 'operator()'

If I omit the auto arguments with gcc, it reports:

t.cpp:6:31: error: 'operator()' not defined

However, the auto trick does work with clang - I have more complex lambdas with
which it does work. I find the trick very useful. Could you make it work with
clang every time, just like is the case with gcc?

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20200917/b8c3cc05/attachment.html>


More information about the llvm-bugs mailing list