Nowhere in your code you attempt to pass a reference to a reference. Inside f
expression x
produces an lvalue of type int
. It is not a reference. Expressions in C++ never produce accessible results of reference type, since any results of reference type are immediately interpreted by the language as lvalues of non-reference type.
See 5/5
If an expression initially has the type “reference to T” (8.3.2,
8.5.3), the type is adjusted to T prior to any further analysis. The expression designates the object or function denoted by the reference,
and the expression is an lvalue or an xvalue, depending on the
expression.
P.S. I'm not sure what you mean by "Doesn't the formal parameter of g() qualify as a reference to a reference". The formal parameter of g
is declared as int &
. Where do you see "a reference to a reference" here?