[llvm-bugs] [Bug 52322] New: C++20 warning: template lambda "does not declare any constructor to initialize its non-modifiable members"
via llvm-bugs
llvm-bugs at lists.llvm.org
Tue Oct 26 07:37:40 PDT 2021
https://bugs.llvm.org/show_bug.cgi?id=52322
Bug ID: 52322
Summary: C++20 warning: template lambda "does not declare any
constructor to initialize its non-modifiable members"
Product: clang
Version: trunk
Hardware: PC
OS: Linux
Status: NEW
Severity: normal
Priority: P
Component: Frontend
Assignee: unassignedclangbugs at nondot.org
Reporter: jake.arkinstall at gmail.com
CC: llvm-bugs at lists.llvm.org, neeilans at live.com,
richard-llvm at metafoo.co.uk
In this toy code, clang 13 warns that a lambda function isn't initializing
captured members.
https://godbolt.org/z/hhszT4fqj
I don't know whether (1) this is a false positive warning, (2) the warning is
legitimate and the generated code is incorrect, or (3) the code is truly
invalid and the warning is a side-effect of that.
I'm leaning towards #1. I'd rule #2 out because it still produces the correct
output, and I'd (tentatively) rule #3 out because GCC and MSVC don't see any
problems with the code (Clang 12 segfaults on it, which appears to be a parsing
issue).
> <source>:9:48: warning: class '' does not declare any constructor to initialize its non-modifiable members
> TypeList<tail...>::max(comparison, [&comparison, &callback]<typename S>() {
> ^
> <source>:9:48: note: in instantiation of member class '' requested here
> <source>:17:31: note: in instantiation of function template specialization 'TypeList<int, char>::max((lambda at <source>:34:9) &, (lambda at <source>:9:48) &&)::(anonymous class)::operator()<char>' requested here
> callback.template operator()<head>();
> ^
> <source>:9:32: note: in instantiation of function template specialization 'TypeList<char>::max<(lambda at <source>:34:9) &, (lambda at <source>:9:48)>' requested here
> TypeList<tail...>::max(comparison, [&comparison, &callback]<typename S>() {
> ^
> <source>:9:32: note: in instantiation of function template specialization 'TypeList<int, char>::max<(lambda at <source>:34:9) &, (lambda at <source>:9:48)>' requested here
> <source>:33:11: note: in instantiation of function template specialization 'TypeList<long, int, char>::max<(lambda at <source>:34:9), (lambda at <source>:35:9)>' requested here
> list::max(
> ^
> <source>:9:50: note: reference member '' will never be initialized
> TypeList<tail...>::max(comparison, [&comparison, &callback]<typename S>() {
> ^
> <source>:9:63: note: reference member '' will never be initialized
> TypeList<tail...>::max(comparison, [&comparison, &callback]<typename S>() {
--
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/20211026/8d51ce9e/attachment-0001.html>
More information about the llvm-bugs
mailing list