Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in
  • F Frama Clang
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 3
    • Issues 3
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 1
    • Merge requests 1
  • Deployments
    • Deployments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Container Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Commits
  • Issue Boards
Collapse sidebar
  • pub
  • Frama Clang
  • Merge requests
  • !1

[libc++] Fix std::forward for r-value references

  • Review changes

  • Download
  • Email patches
  • Plain diff
Closed Stefan Gränitz requested to merge weliveindetail/frama-clang:forward-rvalue-ref into master Jul 08, 2021
  • Overview 2
  • Commits 0
  • Changes 0

The explicit cast is necessary even though the value for t is passed in as an r-value, because it becomes an l-value as soon as it is assigned to the variable.

Without the change in libc++ the updated test fails with:

In file included from tests/stl/stl_utility.cpp:1:
share/libc++/utility:58:12: error: rvalue reference to type 'int' cannot bind to lvalue of type 'typename remove_reference<int>::type' (aka 'int')
    return t;
           ^
tests/stl/stl_utility.cpp:18:20: note: in instantiation of function template specialization 'std::forward<int>' requested here
  int && xr = std::forward<int>(x + 1);
                   ^
code generation aborted due to one compilation error

The change follows the implementation in LLVM libcxx: https://github.com/llvm/llvm-project/blob/abfa950d86da1737/libcxx/include/__utility/forward.h#L35

Assignee
Assign to
Reviewers
Request review from
Time tracking
Source branch: forward-rvalue-ref