[LLVMbugs] [Bug 22604] New: By-copy capture-default causes "const" unless "mutable" despite non-odr-use

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Mon Feb 16 10:39:25 PST 2015


http://llvm.org/bugs/show_bug.cgi?id=22604

            Bug ID: 22604
           Summary: By-copy capture-default causes "const" unless
                    "mutable" despite non-odr-use
           Product: clang
           Version: trunk
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: C++14
          Assignee: unassignedclangbugs at nondot.org
          Reporter: hstong at ca.ibm.com
                CC: llvmbugs at cs.uiuc.edu
    Classification: Unclassified

In the following, it is observed that (consistent with the resolution to
DR1472) the appearance of "ref" in the lambda did not cause the creation of a
corresponding member of the closure type since there is no complaint from Clang
about the deleted copy constructor.

Since said appearance of "ref" does not refer to a member of the closure type,
it appears that Clang wrong in its complaining about "const" in the output
below. At the same time, adding "mutable" to the lambda-declarator should not
make a difference, but it does with Clang.

### SOURCE (<stdin>):
struct A {
   A() = default;
   A(const A &) = delete;
} globalA;

int main() {
   A &ref = globalA, *bar(A &);
   [=]() { bar(ref); };
}


### COMPILER INVOCATION:
clang -cc1 -Wno-unused-value -std=c++11 -x c++ -


### ACTUAL OUTPUT:
<stdin>:8:16: error: binding of reference to type 'A' to a value of type 'const
A' drops qualifiers
   [=]() { bar(ref); };
               ^~~
<stdin>:7:30: note: passing argument to parameter here
   A &ref = globalA, *bar(A &);
                             ^
1 error generated.


### EXPECTED OUTPUT:
(Clean compile)


### COMPILER VERSION INFO:
clang version 3.7.0 (trunk 229397)
Target: x86_64-unknown-linux-gnu
Thread model: posix
Found candidate GCC installation:
/usr/local/gcc-4.8.2/lib/gcc/x86_64-unknown-linux-gnu/4.8.2
Selected GCC installation:
/usr/local/gcc-4.8.2/lib/gcc/x86_64-unknown-linux-gnu/4.8.2
Candidate multilib: .;@m64
Selected multilib: .;@m64

-- 
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/20150216/bf987882/attachment.html>


More information about the llvm-bugs mailing list