Quantcast
Channel: Active questions tagged gcc - Stack Overflow
Viewing all articles
Browse latest Browse all 22298

msvc cannot initialize rvalue reference from value [duplicate]

$
0
0

MSVC (std:c++14) is complaining when initializing an rvalue reference using non-static data member of a prvalue (returned by function call).

The code is as follows (or see Compiler Explorer):

struct R {};struct A {    R r;    R getR() { return r; }};A getA() { return {}; };int main() {    A &&aa = A();            // okay    A &&aaa = getA();        // okay    R &&rr = getA().r;       // should be okay, but not}

Both GCC and Clang seem okay, and MSVC with /std:c++20 is okay as well. Is this a compliance issue of MSVC or am I misunderstanding something?


Viewing all articles
Browse latest Browse all 22298

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>