Project

General

Profile

Actions

Bug #3357

closed

Clang reports multiple "moving a temporary object prevents copy elision" warnings

Added by Alex Afanasyev over 8 years ago. Updated over 8 years ago.

Status:
Closed
Priority:
Normal
Category:
Build
Target version:
Start date:
Due date:
% Done:

100%

Estimated time:

Description

Clang 3.7 found several instances of non-optimized code:

../tests/unit-tests/name.t.cpp:167:34: error: moving a temporary object prevents copy elision [-Werror,-Wpessimizing-move]
  BOOST_REQUIRE_NO_THROW(name2 = std::move(Name(nameUri)));

../src/security/key.cpp:143:22: error: moving a temporary object prevents copy elision [-Werror,-Wpessimizing-move]
    m_certificates = std::move(CertificateContainer(m_impl->getCertificatesOfKey(m_id, m_keyId),
                     ^
../src/security/key.cpp:143:22: note: remove std::move call here
    m_certificates = std::move(CertificateContainer(m_impl->getCertificatesOfKey(m_id, m_keyId),
                     ^~~~~~~~~~
../src/security/pib.cpp:90:20: error: moving a temporary object prevents copy elision [-Werror,-Wpessimizing-move]
    m_identities = std::move(IdentityContainer(m_impl->getIdentities(), m_impl));
                   ^
../src/security/pib.cpp:90:20: note: remove std::move call here
    m_identities = std::move(IdentityContainer(m_impl->getIdentities(), m_impl));
                   ^~~~~~~~~~                                                  ~
../src/security/pib.cpp:111:25: error: moving a temporary object prevents copy elision [-Werror,-Wpessimizing-move]
    m_defaultIdentity = std::move(Identity(m_impl->getDefaultIdentity(), m_impl, false));
                        ^
../src/security/pib.cpp:111:25: note: remove std::move call here
    m_defaultIdentity = std::move(Identity(m_impl->getDefaultIdentity(), m_impl, false));
                        ^~~~~~~~~~                                                     ~

../src/exclude.cpp:123:27: error: moving a temporary object prevents copy elision [-Werror,-Wpessimizing-move]
      excludedComponent = std::move(name::Component(*i));
                          ^
../src/exclude.cpp:123:27: note: remove std::move call here
      excludedComponent = std::move(name::Component(*i));
                          ^~~~~~~~~~                   ~

../src/security/identity.cpp:106:14: error: moving a temporary object prevents copy elision [-Werror,-Wpessimizing-move]
    m_keys = std::move(KeyContainer(m_name, m_impl->getKeysOfIdentity(m_name), m_impl));
             ^
../src/security/identity.cpp:106:14: note: remove std::move call here
    m_keys = std::move(KeyContainer(m_name, m_impl->getKeysOfIdentity(m_name), m_impl));
             ^~~~~~~~~~                                                               ~
../src/security/identity.cpp:118:18: error: moving a temporary object prevents copy elision [-Werror,-Wpessimizing-move]
  m_defaultKey = std::move(Key(m_name, keyId, m_impl));
                 ^
../src/security/identity.cpp:118:18: note: remove std::move call here
  m_defaultKey = std::move(Key(m_name, keyId, m_impl));
                 ^~~~~~~~~~                          ~
../src/security/identity.cpp:138:20: error: moving a temporary object prevents copy elision [-Werror,-Wpessimizing-move]
    m_defaultKey = std::move(Key(m_name, m_impl->getDefaultKeyOfIdentity(m_name), m_impl));
                   ^
../src/security/identity.cpp:138:20: note: remove std::move call here
    m_defaultKey = std::move(Key(m_name, m_impl->getDefaultKeyOfIdentity(m_name), m_impl));
                   ^~~~~~~~~~                                                            ~
../src/name.cpp:173:11: error: moving a temporary object prevents copy elision [-Werror,-Wpessimizing-move]
  *this = std::move(Name(uri));
          ^
../src/name.cpp:173:11: note: remove std::move call here
  *this = std::move(Name(uri));
          ^~~~~~~~~~         ~
../src/name.cpp:179:11: error: moving a temporary object prevents copy elision [-Werror,-Wpessimizing-move]
  *this = std::move(Name(uri));
          ^
../src/name.cpp:179:11: note: remove std::move call here
  *this = std::move(Name(uri));
          ^~~~~~~~~~         ~
../src/name.cpp:374:10: error: moving a temporary object prevents copy elision [-Werror,-Wpessimizing-move]
  name = std::move(Name(inputString));
         ^
../src/name.cpp:374:10: note: remove std::move call here
  name = std::move(Name(inputString));
         ^~~~~~~~~~                 ~
Actions #1

Updated by Davide Pesavento over 8 years ago

  • Subject changed from Multiple instances of moving a temporary object prevents copy elision to Clang reports multiple "moving a temporary object prevents copy elision" warnings

Ah yes, I saw this some time ago but forgot to report.

Actions #2

Updated by Davide Pesavento over 8 years ago

  • Status changed from Code review to Closed
Actions

Also available in: Atom PDF