Bug 87638 - [C++14] lambda init-capture fails for const references still
Summary: [C++14] lambda init-capture fails for const references still
Status: NEW
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 9.0
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords: rejects-valid
Depends on:
Blocks:
 
Reported: 2018-10-17 22:02 UTC by Hubert Tong
Modified: 2024-04-17 05:26 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2024-04-16 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Hubert Tong 2018-10-17 22:02:31 UTC
The issue reported by PR 66735 still exists. GCC would not bind const-reference init-captures to prvalues or xvalues.

### SOURCE (<stdin>):
const int &&f();
void g() { [&r = f()] { }(); }


### COMPILER INVOCATION COMMAND:
g++ -fsyntax-only -x c++ -std=c++14 -


### ACTUAL COMPILER OUTPUT:
<stdin>: In function 'void g()':
<stdin>:2:20: error: cannot capture 'f()' by reference


### EXPECTED COMPILER OUTPUT:
(Clean compile).


### COMPILER VERSION INFO (g++ -v):
Using built-in specs.
COLLECT_GCC=/opt/wandbox/gcc-head/bin/g++
COLLECT_LTO_WRAPPER=/opt/wandbox/gcc-head/libexec/gcc/x86_64-pc-linux-gnu/9.0.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: ../source/configure --prefix=/opt/wandbox/gcc-head --enable-languages=c,c++ --disable-multilib --without-ppl --without-cloog-ppl --enable-checking=release --disable-nls --enable-lto LDFLAGS=-Wl,-rpath,/opt/wandbox/gcc-head/lib,-rpath,/opt/wandbox/gcc-head/lib64,-rpath,/opt/wandbox/gcc-head/lib32
Thread model: posix
gcc version 9.0.0 20181016 (experimental) (GCC)
Comment 1 Andrew Pinski 2021-12-14 04:21:52 UTC
Confirmed.