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: unassignedclangb...@nondot.org
          Reporter: jake.arkinst...@gmail.com
                CC: llvm-bugs@lists.llvm.org, neeil...@live.com,
                    richard-l...@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.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to