Print

Print


Doing some test:
```
$ cat test.cpp
#include <iostream>

class A {
public:
  A();
  A(const A&);
  A(const A&&);
};

A::A() {
  std::cout << "A::A()" << std::endl;
}

A::A(const A&) {
  std::cout << "A::A(const A&)" << std::endl;
}

A::A(const A&&) {
  std::cout << "A::A(const A&&)" << std::endl;
}

A A1() {
  A a;
  return a;
}

A A2() {
  A a;
  return std::move(a);
}

int main() {
  A a1(A1());
  A a2(A2());
}
```
On Fedora 32 (gcc 10):
```
$ g++ --version
g++ (GCC) 10.1.1 20200507 (Red Hat 10.1.1-1)

$ g++ -std=c++11 -o test test.cpp
$ ./test
A::A()
A::A()
A::A(const A&&)
$ g++ -std=c++14 -o test test.cpp
$ ./test
A::A()
A::A()
A::A(const A&&)
$ g++ -std=c++17 -o test test.cpp
$ ./test
A::A()
A::A()
A::A(const A&&)
$ g++ -std=c++20 -o test test.cpp
$ ./test
A::A()
A::A()
A::A(const A&&)
```
On CentOS 8 (gcc 8):
```
$ g++ --version
g++ (GCC) 8.3.1 20191121 (Red Hat 8.3.1-5)

$ g++ -std=c++11 -o test test.cpp
$ ./test 
A::A()
A::A()
A::A(const A&&)
$ g++ -std=c++14 -o test test.cpp
$ ./test 
A::A()
A::A()
A::A(const A&&)
$ g++ -std=c++17 -o test test.cpp
$ ./test 
A::A()
A::A()
A::A(const A&&)
$ g++ -std=c++20 -o test test.cpp
g++: error: unrecognized command line option ‘-std=c++20’; did you mean ‘-std=c++2a’?
$ g++ -std=c++2a -o test test.cpp
$ ./test 
A::A()
A::A()
A::A(const A&&)
```
On Centos 7 (gcc 4.8)
```
$ g++ --version
g++ (GCC) 4.8.5 20150623 (Red Hat 4.8.5-39)

$ g++ -std=c++11 -o test test.cpp 
$ ./test
A::A()
A::A()
A::A(const A&&)
$ g++ -std=c++14 -o test test.cpp
g++: error: unrecognized command line option '-std=c++14'
$ g++ -std=c++1y -o test test.cpp
$ ./test
A::A()
A::A()
A::A(const A&&)
```
On CentOS 6 (gcc 4.4):
```
$ g++ --version
g++ (GCC) 4.4.7 20120313 (Red Hat 4.4.7-23)

$ g++ -std=c++11 -o test test.cpp
cc1plus: error: unrecognized command line option "-std=c++11"
$ g++ -std=c++0x -o test test.cpp
$ ./test 
A::A()
A::A()
A::A(const A&&)
```
The result is the same in all cases - the return std::move is pessimising and results in a extra call to the move constructor in all cases, including CentOS 6 and 7.

-- 
You are receiving this because you commented.
Reply to this email directly or view it on GitHub:
https://github.com/xrootd/xrootd/pull/1209#issuecomment-646496459
########################################################################
Use REPLY-ALL to reply to list

To unsubscribe from the XROOTD-DEV list, click the following link:
https://listserv.slac.stanford.edu/cgi-bin/wa?SUBED1=XROOTD-DEV&A=1