Skip to content

GitLab

  • Menu
Projects Groups Snippets
    • Loading...
  • 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 2
    • Issues 2
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 3
    • Merge requests 3
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Monitor
    • Monitor
    • Incidents
  • Packages & Registries
    • Packages & Registries
    • Package Registry
    • Container Registry
    • Infrastructure Registry
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • pub
  • Frama Clang
  • Merge requests
  • !1

Closed
Created Jul 08, 2021 by Stefan Gränitz@weliveindetail
  • Report abuse
Report abuse

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

  • Overview 2
  • Commits 0
  • Pipelines 2
  • 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
Reviewer
Request review from
Time tracking
Source branch: forward-rvalue-ref