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

            Bug ID: 47569
           Summary: 'const' qualifier on referenced decltype(type) isn't
                    allowed by clang++
           Product: clang
           Version: trunk
          Hardware: PC
                OS: FreeBSD
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: C++11
          Assignee: [email protected]
          Reporter: [email protected]
                CC: [email protected], [email protected],
                    [email protected], [email protected],
                    [email protected]

Created attachment 23980
  --> https://bugs.llvm.org/attachment.cgi?id=23980&action=edit
testcase-c++-const-decltype.cpp

The attached testcase adds 'const' and the reference symbol & to
decltype(Cls::field) to construct the return type of a function.

Compilation fails:
> testcase-c++-const-decltype.cpp:10:2: warning: 'const' qualifier on reference 
> type 'decltype(X::u[0][0][0])' (aka 'unsigned int &') has no effect 
> [-Wignored-qualifiers]
>         const decltype(X::u[0][0][0])& getXu(unsigned i1, unsigned i2, 
> unsigned i3) const {
>         ^~~~~~
> testcase-c++-const-decltype.cpp:11:10: error: binding reference of type 
> 'unsigned int' to value of type 'const unsigned int' drops 'const' qualifier
>                 return x.u[i1][i2][i3];
>                        ^~~~~~~~~~~~~~~

Replacing decltype(X::u[0][0][0]) with "unsigned" helps, but
decltype(X::u[0][0][0]) resolves to the same "unsigned" which should make
"const decltype(X::u[0][0][0])&" equivalent to "const unsigned&".

The testcase fails with clang-10, clang-11, clang-11, clang-12.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to