C++

Cannot Bind Rvalue Reference Fix

An rvalue reference parameter is a promise that the function may treat its argument as disposable. A named variable makes the opposite promise: it has a life after the call, so the compiler refuses to bind it silently. This guide reads the GCC diagnostic word by word, shows the one named-variable trap that produces the same error, and fixes each call by stating the real intent at the call site or in the signature.

Written November 28, 2026 · Tested with GCC 13.3.0 · 12 min read

By the end of this guide
  • The failure: a named variable offered to an rvalue reference
  • The contrast: a literal binds without help
  • The same error in a declaration
  • Fix 1: say it with std::move at the call site

Written November 28, 2026

Tested with GCC 13.3.0

What this guide is

Every expression in C++ has a value category as well as a type. The name of a variable is an lvalue: it identifies an object whose address can be taken and whose value persists past the expression that mentions it. A literal such as 42 is a prvalue: it computes a value but names no lasting object. An rvalue is a prvalue or an xvalue, and an rvalue reference — written int&&, with two ampersands — can be initialized only from an rvalue. Offer it the name of a variable of its own type and the program is ill-formed, with this error as the report. (A variable of a different, convertible type is the one exception, covered in the rule section below: the compiler converts it first, and the reference binds to the converted temporary.)

That restriction is the feature, not an obstacle in front of it. A parameter of type int&& advertises that the function may move from its argument — take its value or its resources and leave it in a valid but unspecified state. Doing that silently to a variable the caller still owns would be a nasty surprise: the caller would read the variable after the call and find it changed or emptied, with nothing at the call site saying that was allowed. The compiler therefore requires the caller to say so explicitly, and rejects the binding at the point it is attempted, in a function argument and in a variable declaration alike — function arguments are initialized from the caller's expressions by the same reference-initialization rules as variables, so one rule produces both failures in this guide.

This guide works through the failing call first, then the contrast program that does compile, where the same function accepts a literal directly. It then covers the classic trap — a variable declared as an rvalue reference is itself an lvalue when named — and the declaration form of the same error, before showing the three fixes: std::move at the call site when the caller really is handing the object over, a const lvalue reference parameter when the function only reads, and a forwarding reference when one function must accept both named objects and temporaries.

Build every program in this guide with g++ -std=c++20 -g. Nothing here needs C++20 specifically; value categories, rvalue references, and std::move behave the same way in C++11 and later.

The failure: a named variable offered to an rvalue reference

The smallest failing program is a function that takes an rvalue reference and a call that passes a named variable:

C++
void f(int&& value) {}

int main() {
    int x = 1;
    f(x);
    return 0;
}
Terminal
$ g++ -std=c++20 -g -o repro repro.cpp
repro.cpp: In function ‘int main()’:
repro.cpp:5:7: error: cannot bind rvalue reference of type ‘int&&’ to lvalue of type ‘int’
    5 |     f(x);
      |       ^
repro.cpp:1:14: note:   initializing argument 1 of ‘void f(int&&)’
    1 | void f(int&& value) {}
      |        ~~~~~~^~~~~

Read the error in its three named parts, because every variant of this diagnostic uses the same three. The reference being initialized is an rvalue reference of type 'int&&': the double ampersand is the whole story — this parameter accepts only values the caller is done with. The thing offered to it is an lvalue of type 'int': the argument x is the name of a variable, and a variable name is an lvalue regardless of the value it currently holds. And the verb is cannot bind: reference initialization is a binding, not a copy, so for a same-type argument like x there is no fallback in which the compiler quietly copies x into a temporary and binds the parameter to that instead. The caret sits under x, the argument — the declaration of f is fine in itself; the argument is what fails it.

The output also carries a note: line, initializing argument 1 of 'void f(int&&)', with a caret span under the parameter declaration on line 1. Read the pair together: the error line gives the call site and the argument that failed, the note gives the parameter that the argument was trying to initialize. In a long build log that note is the line that tells you which function's signature is involved, and it is worth looking for before changing anything, because the fix may belong in the signature rather than at any one call.

Note what the error is not. It is not a complaint that x has the wrong type — the type named on both sides is int. No change to the value stored in x, and no change to how x was initialized, affects the outcome, because the failing property is the value category of the argument expression, not its type or its value. That is also why searching on the type in the message so often misleads: two calls can agree on every type in sight and still differ on this error, purely because one argument named an object and the other computed a value.

The contrast: a literal binds without help

The same function accepts a literal with no cast and no helper:

C++
#include <iostream>

void f(int&& value) {
    std::cout << "f got " << value << '\n';
}

int main() {
    f(42);
    return 0;
}
Terminal
$ g++ -std=c++20 -g -o literal literal.cpp
$ ./literal
f got 42

The literal 42 is a prvalue, and a prvalue is an rvalue, so it is exactly what an int&& parameter asks for: a value with no lasting name, which the function may use up freely because nobody can refer to it after the call. This contrast is the fastest diagnostic test for the error. If replacing the argument with a literal of the same type makes the call compile, the types were never the problem — the original argument was an lvalue, and the remaining question is only which fix below matches the intent.

Inside f, one detail is worth fixing in mind before the trap in the next section: the parameter name value is itself an lvalue expression inside the function body. The function can read it, assign to it, and take its address like any variable — which is why the std::cout line above works. Rvalue status was a property of the argument expression at the call site, not a property that follows the object around afterward. That single fact explains the most confusing form of this error.

The trap: a named rvalue reference is an lvalue

Trap
This program looks like it should work. The variable is declared with an rvalue reference type, so passing it to a function that wants an rvalue reference feels like an exact match:
C++
void f(int&& value) {}

int main() {
    int&& r = 42;
    f(r);
    return 0;
}
Terminal
$ g++ -std=c++20 -g -o named named.cpp
named.cpp: In function ‘int main()’:
named.cpp:5:7: error: cannot bind rvalue reference of type ‘int&&’ to lvalue of type ‘int’
    5 |     f(r);
      |       ^
named.cpp:1:14: note:   initializing argument 1 of ‘void f(int&&)’
    1 | void f(int&& value) {}
      |        ~~~~~~^~~~~

The error is identical to the first failure, word for word, and that identity is the lesson. The declaration int&& r = 42; is legal — the literal is a prvalue, so the rvalue reference binds, and the temporary it binds to lives as long as r does. But in the next line, the expression r is the name of a variable, and the name of a variable is an lvalue even when the variable's type is an rvalue reference. Value category is a property of expressions, not of declared types: once anything has a name, using that name is an lvalue expression, because the named object can be referred to again after the call — exactly the situation an int&& parameter exists to rule out unless the caller opts in.

The fix for this shape is the same as for any other named variable: f(std::move(r)); if r is truly finished, or a different parameter type on f if it is not. There is no declaration-side spelling that makes a named variable forward itself as an rvalue automatically, and that is deliberate — a variable that silently emptied itself on every pass-along would be unusable in any function with two calls in a row.

The same error in a declaration

The binding rule is not specific to function calls. Initializing an rvalue reference variable directly from a named variable of the same type fails the same way:

C++
int main() {
    int x = 1;
    int&& r2 = x;
    return 0;
}
Terminal
$ g++ -std=c++20 -g -o decl decl.cpp
decl.cpp: In function ‘int main()’:
decl.cpp:3:16: error: cannot bind rvalue reference of type ‘int&&’ to lvalue of type ‘int’
    3 |     int&& r2 = x;
      |                ^

The wording matches the call form except for what is missing: there is no note: line, because there is no parameter being initialized — the reference in the declaration is the binding site, and the caret under x names the lvalue that was offered. Seeing this form in the wild usually means code was rearranged — a value that used to be a temporary or a std::move result is now stored in a named variable first — and the repair is the same decision as at a call site: write int&& r2 = std::move(x); only if x is genuinely done, and otherwise declare r2 as the reference type the intent actually needs, most often int& or const int&.

Fix 1: say it with std::move at the call site

When the caller really is handing the object over — it will not read the variable again except to assign to it or destroy it — std::move is the explicit opt-in the parameter type is asking for:

C++
#include <iostream>
#include <utility>

void f(int&& value) {
    std::cout << "f got " << value << '\n';
}

int main() {
    int x = 1;
    f(std::move(x));
    std::cout << "x after = " << x << '\n';
    return 0;
}
Terminal
$ g++ -std=c++20 -g -o movefix movefix.cpp
$ ./movefix
f got 1
x after = 1

std::move does not move anything by itself. It is a cast: it converts its argument into an xvalue, an expiring value, which is an rvalue and therefore binds to int&&. The actual moving, if any, is done by whatever the function does with its parameter. That is why the second output line reads x after = 1: f only reads its parameter, and for a scalar type like int there is nothing to take — the value is copied into the function's use, and the caller's variable keeps its value. std::move on an int is permission, not an operation.

The picture changes for a type that owns resources, such as std::string, when the function actually moves from its parameter:

C++
#include <iostream>
#include <string>
#include <utility>

void take(std::string&& s) {
    std::string local = std::move(s);
    std::cout << "take moved " << local << '\n';
}

int main() {
    std::string s = "hello";
    take(std::move(s));
    std::cout << "s after = [" << s << "]\n";
    std::cout << "s size = " << s.size() << '\n';
    return 0;
}
Terminal
$ g++ -std=c++20 -g -o strmove2 strmove2.cpp
$ ./strmove2
take moved hello
s after = []
s size = 0

Here the string's contents really did transfer: local holds hello, and the caller's s prints empty with size 0 afterward on this standard library. Two cautions keep this output from being over-read. First, the empty source is a property of this standard library's string move — the standard's guarantee for a moved-from library object is only that it is in a valid but unspecified state, so portable code may assign to s or destroy it after the move, but may not rely on finding it empty. Second, the move happened because take moved out of its parameter with its own std::move(s) — the parameter name is an lvalue inside the function, as the trap section showed. A take that only reads its parameter leaves the caller's string untouched, std::move at the call site notwithstanding. Permission at the call site plus a move inside the function are both required; either one alone transfers nothing.

Fix 2: take a const lvalue reference when the function only reads

Many occurrences of this error are a misspelled signature, not a wrong call. If the function never modifies its argument and never moves from it, it has no need for the disposability an int&& demands, and the parameter type that states reading intent — const int& — accepts both named variables and temporaries:

C++
#include <iostream>

void show(const int& value) {
    std::cout << "show = " << value << '\n';
}

int main() {
    int x = 7;
    show(x);
    show(42);
    return 0;
}
Terminal
$ g++ -std=c++20 -g -o constfix constfix.cpp
$ ./constfix
show = 7
show = 42

Both calls now compile, because a const lvalue reference binds to lvalues and rvalues alike: it copies neither, and its promise not to modify the argument is what makes binding it to a temporary safe. This is the fix to reach for first whenever the function body only reads — one edit to the declaration repairs every failing call site at once, and it also keeps every call that already worked working. Check the body before applying it: a body that writes through the parameter, or moves from it, is telling you the intent really was ownership, and this fix would only move the error inside the function.

Fix 3: a forwarding reference when both kinds of argument are real

When one function genuinely must accept named objects and temporaries through a single signature — typically a wrapper that passes its argument on to something else — a deduced template parameter of the form T&& is a forwarding reference, and it binds both:

C++
#include <iostream>
#include <utility>

template <typename T>
void g(T&& value) {
    std::cout << "g called\n";
}

int main() {
    int x = 1;
    g(x);
    g(42);
    g(std::move(x));
    return 0;
}
Terminal
$ g++ -std=c++20 -g -o fwd fwd.cpp
$ ./fwd
g called
g called
g called

All three calls compile. When the argument is an lvalue, T is deduced as an lvalue reference type and the parameter becomes an lvalue reference; when the argument is an rvalue, T is deduced as the plain type and the parameter is an rvalue reference. The catch is in what the function does next: inside g, the name value is an lvalue, so passing it onward to a function that wants an rvalue reference needs std::forward<T>(value), which restores the category the caller supplied — a plain std::move(value) would claim the argument is disposable even when the caller passed a variable it still owns. A forwarding reference is also only this flexible in a deduced template context: writing int&& in an ordinary function, as the failing programs do, is a plain rvalue reference with no such dual behavior. Reach for this fix when the dual acceptance is the actual requirement; for a fixed intent, the plainer signature from Fix 1 or Fix 2 states it better.

Similar cases: const&& and the reverse error

Adding const to an rvalue reference does not rescue an lvalue argument. A const int&& parameter still requires an rvalue:

C++
void f(const int&& value) {}

int main() {
    int x = 1;
    f(x);
    return 0;
}
Terminal
$ g++ -std=c++20 -g -o constref constref.cpp
constref.cpp: In function ‘int main()’:
constref.cpp:5:7: error: cannot bind rvalue reference of type ‘const int&&’ to lvalue of type ‘int’
    5 |     f(x);
      |       ^
constref.cpp:1:20: note:   initializing argument 1 of ‘void f(const int&&)’
    1 | void f(const int&& value) {}
      |        ~~~~~~~~~~~~^~~~~

The only change in the diagnostic is the reference type named in it, now const int&&. The const restricts what the function may do with the argument; it does not widen which arguments may bind. A const&& parameter is a rare, deliberate choice — it accepts temporaries while promising not to modify them — and it is almost never the fix for this error. When reading is the intent, the binding that accepts everything is const&, with one ampersand, as in Fix 2.

The reverse error is a different guide's territory and is worth telling apart at a glance, because the two messages differ by only a few words. This guide's error offers an lvalue to an rvalue reference (int&&): the caller has a named object and the signature demands a disposable value, and the crossings are std::move, const&, or a forwarding reference. The reverse error offers an rvalue to a non-const lvalue reference (int&): the caller has a temporary and the signature promises to write back through it, and its crossings are a const& parameter, a named variable at the call site, or an && parameter for ownership. Reading which side of the message names the reference and which names the argument tells you which of the two you have before you read anything else: the first type named is the reference being initialized, the second is the expression being offered.

The rule underneath the error

An rvalue reference requires an rvalue initializer; a named variable is an lvalue, whatever its declared type. Every instance of this error is therefore a mismatch between intent and spelling at one binding site: either the code offered an object it still owns where the signature demanded a disposable value, or the signature demanded disposability the function's body never uses.

One carve-out bounds that rule, and it is the indirect binding in the reference-initialization rules: when the lvalue's type is different from the referenced type but convertible to it, the compiler converts the lvalue to a prvalue of the referenced type, materializes a temporary, and binds the rvalue reference to that temporary. The call compiles, and the function sees the converted value, not the caller's variable:

C++
#include <iostream>

void f(int&& value) {
    std::cout << "f " << value << '\n';
}

int main() {
    double dv = 2.9;
    f(dv);
    std::cout << "dv after = " << dv << '\n';
    return 0;
}
Terminal
$ g++ -std=c++20 -g -o conv conv.cpp
$ ./conv
f 2
dv after = 2.9

The double lvalue dv never binds: it is converted to the prvalue 2, a temporary int is materialized, and the parameter binds to that temporary — which is why f prints the truncated 2 and dv still holds 2.9 afterward. This is not a way around the error for same-type arguments, and it is rarely a deliberate fix: a call that compiles by this route is passing a converted copy, so a function that believes it received the caller's object is working on a temporary instead. Treat a mixed-type call that compiles as a conversion to audit, not as evidence that the binding rule has an exception for named variables of the parameter's own type.

So the diagnostic always contains the two coordinates needed to fix it — the binding site in the error: line, and, for the call form, the parameter in the note: line. The fix is always a decision about intent: if the caller is done with the object, keep && and cross explicitly with std::move; if the function only reads, the parameter is misspelled and should be const&; if both kinds of argument must be accepted by one signature, make it a forwarding reference in a template and forward with std::forward. No instance of this error is fixed by removing the caller's variable or by sprinkling std::move on arguments whose values the caller still needs — std::move is a statement that the object may be emptied, and writing it where that is not true converts a compile error into a runtime surprise.

The fixes, ranked

Pass std::move(name) when the caller is truly done with the object. Ranked first for a correctly spelled && signature, because it changes nothing about the function's contract and states the handover exactly where it happens, at the call site. Before applying it, scan the rest of the function for later reads of the variable: a later read that needs the old value means the handover was not real, and one of the signature fixes below is the honest repair.

Change the parameter to const T& when the function only reads. The fix the majority of accidental occurrences need: the signature over-promised, the call sites were innocent, and one edit to the declaration repairs every failing call at once while also accepting temporaries. Check the function body for writes or moves through the parameter before applying it.

Make the parameter a forwarding reference when one signature must take both. A deduced T&& in a template accepts lvalues and rvalues and preserves each caller's category with std::forward<T>. Reach for it when the function is a genuine pass-through; for a function with a single fixed intent, it adds deduction rules where a plain signature would state the contract directly.

Add overloads instead of replacing the signature, when two intents are both real. A const T& overload for reading callers alongside a T&& overload for handing-over callers lets each call site pick by argument category, with std::move as the explicit selector for the second. Reach for this last: a single signature that states one intent is easier to audit than a pair whose selection depends on the argument's category.

Which fix for which cause

What the diagnostic shows Cause Fix
Error at a call, argument is a named variable Named object offered where a disposable value is required std::move(name) if the object is truly disposable; const T& parameter if the function only reads
Error at a call, argument is a named rvalue reference variable A variable name is an lvalue whatever its declared type Same as any named variable: std::move(r), or fix the signature
Error at T&& name = variable; The declaration form of the same binding std::move in the initializer, or declare the reference as T& / const T&
Error names a const T&& parameter and an lvalue argument const restricts use, it does not widen binding const T& parameter for reading; std::move for a real handover
Error appears after changing the parameter to const& The body writes through the parameter or moves from it The intent was ownership: restore && and fix the call sites
Wrapper must accept variables and temporaries alike A plain T&& binds rvalues only Forwarding reference T&& in a template, forwarded with std::forward<T>

Checklist

  • Read the error's three parts before editing: the reference type named first is the spelling to question, and the category named second — lvalue — is the property of the argument that no change to its value will remove.
  • For the call form, read the note: line: it names the parameter being initialized, which is where a signature fix belongs, and one signature fix repairs all of that function's failing calls together.
  • Classify the argument expression, not its declared type: the name of any variable is an lvalue, including a variable declared as an rvalue reference; for an argument of the referenced type, only a prvalue, or an xvalue such as a std::move result, binds to a non-const &&.
  • Check the types before predicting this error across types: an lvalue of a different, convertible type does not draw it — the compiler converts it to a prvalue and binds the reference to the converted temporary, so the function receives the converted value, not the variable.
  • Decide the intent before touching the spelling: handover means && plus std::move at the call site, read-only means const&, accept-everything means a forwarding reference in a template.
  • Do not write std::move where the caller still needs the value: for resource-owning types a real move inside the callee can leave the source empty, and the standard guarantees only a valid but unspecified state after a move.
  • Do not expect const to widen an rvalue reference: a const T&& parameter still refuses lvalues; the reference that accepts both for reading is const T&.
  • If the same call also fails in the reverse direction after a signature change, stop and settle the intent first: the two errors are opposites, and alternating between them means the signature and the call sites disagree about whether the function reads, writes back, or takes ownership.

Sources

  • cppreference, Reference initialization — for an rvalue reference being initialized only from an rvalue, for function arguments being initialized by the same rules as variables, for the indirect binding that converts a differently-typed lvalue to a prvalue temporary, and for the binding rules each fix in this guide relies on.
  • cppreference, Value categories — for the name of a variable being an lvalue even when the variable's type is an rvalue reference, for literals being prvalues, and for an rvalue being a prvalue or an xvalue.
  • cppreference, std::move — for std::move indicating that an object may be moved from, for it producing an xvalue equivalent to a cast to an rvalue reference type, and for moved-from standard library objects being in a valid but unspecified state.
  • cppreference, std::forward — for forwarding references in deduced template parameters and for std::forward restoring the value category the caller supplied.

Keep Exploring