[llvm-bugs] [Bug 43842] Non-const ref treated as const-ref in the compiler.
via llvm-bugs
llvm-bugs at lists.llvm.org
Tue Oct 29 14:57:14 PDT 2019
https://bugs.llvm.org/show_bug.cgi?id=43842
Richard Smith <richard-llvm at metafoo.co.uk> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
Resolution|--- |INVALID
--- Comment #1 from Richard Smith <richard-llvm at metafoo.co.uk> ---
In order to determine which 'fn' to call, the compiler needs to check
'is_invocable<F&&, T const&>'. As part of checking whether the lambda is
invokable, the compiler needs to check whether it has a valid return type.
Because the lambda has a deduced return type, the operator() must be
instantiated (with 'auto' = 'const int') to deduce that return type. That
instantiation fails as described in the given diagnostic.
So this is a bug in your code, not a bug in Clang (nor in GCC / ICC / MSVC,
which all reject this the same way).
You can fix your code by giving the lambda an explicit return type rather than
a deduced return type:
instance.fn([](auto& i) -> void {
i = 0;
});
--
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/20191029/4a00c596/attachment.html>
More information about the llvm-bugs
mailing list