[llvm-bugs] [Bug 47569] New: 'const' qualifier on referenced decltype(type) isn't allowed by clang++
via llvm-bugs
llvm-bugs at lists.llvm.org
Thu Sep 17 17:43:53 PDT 2020
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: unassignedclangbugs at nondot.org
Reporter: yuri at tsoft.com
CC: blitzrakete at gmail.com, dgregor at apple.com,
erik.pilkington at gmail.com, llvm-bugs at lists.llvm.org,
richard-llvm at metafoo.co.uk
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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20200918/547aa9a9/attachment.html>
More information about the llvm-bugs
mailing list