https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114561
Bug ID: 114561
Summary: Comma operator with forwarding reference to pointer
raises invalid lvalue required error
Product: gcc
Version: 14.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: [email protected]
Target Milestone: ---
Created attachment 57845
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=57845&action=edit
Source to reproduce bug
Compiling the attached source (cut down example) with `g++ -c fail.cpp` raises
the following error:
fail.cpp: In instantiation of ‘static T Create<T>::create(U&&) [with U = void*
const&; T = MyClass]’:
fail.cpp:38:28: required from here
fail.cpp:31:12: error: lvalue required as unary ‘&’ operand
31 | return T( ( (beforeParam()), (forward<U>(u)) ) );
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
This code is expected to compile correctly. There is no unary '&' operator in
use.
This seems to be caused by a combination of using the comma operator and
calling `create` with a pointer variable (using nullptr directly compiles, as
shown in the code comment).