[Bug c++/114561] New: Comma operator with forwarding reference to pointer raises invalid lvalue required error

2024-04-02 Thread Liam.Jackson--- via Gcc-bugs
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: liam.jack...@qa-systems.com
  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::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)) ) );
  |^


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).

[Bug c++/114562] New: ICE when trying to bind rvalue reference to lvalue with comma operator and forwarding reference to pointer

2024-04-02 Thread Liam.Jackson--- via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114562

Bug ID: 114562
   Summary: ICE when trying to bind rvalue reference to lvalue
with comma operator and forwarding reference to
pointer
   Product: gcc
   Version: 14.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: liam.jack...@qa-systems.com
  Target Milestone: ---

Created attachment 57846
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=57846&action=edit
Source to reproduce ice

Compiling the attached source would expect to raise an error such as 

error: cannot bind rvalue reference of type 'const void*&&' to lvalue of type
'void* const'

Instead the following ICE occurs:

: In instantiation of 'static T Create::create(U&&) [with U = void*
const&; T = MyClass]':
:34:28:   required from here
   34 | Create::create(MyClass::NONE);
  | ~~~^~~
:28:13: internal compiler error: in convert_like_internal, at
cp/call.cc:8879
   28 |  return T( ( (beforeParam()), (u) ) );
  | ^
0x266d8bc internal_error(char const*, ...)
???:0
0xa572eb fancy_abort(char const*, int, char const*)
???:0
0xa81334 build_new_method_call(tree_node*, tree_node*, vec**, tree_node*, int, tree_node**, int)
???:0
0xa8265b build_special_member_call(tree_node*, tree_node*, vec**, tree_node*, int, int)
???:0
0xa8ff69 perform_direct_initialization_if_possible(tree_node*, tree_node*,
bool, int)
???:0
0xd33f73 build_functional_cast(unsigned int, tree_node*, tree_node*, int)
???:0
0xc92ed3 instantiate_decl(tree_node*, bool, bool)
???:0
0xcbc0ab instantiate_pending_templates(int)
???:0
0xb5a619 c_parse_final_cleanups()
???:0
0xdaf328 c_common_parse_file()
???:0


It may be possible to construct an example source which is expected to compile
successfully yet still triggers this ICE. This has not been explored.

[Bug c++/114561] [11/12 Regression] Comma operator with forwarding reference to pointer raises invalid lvalue required error since r10-7410

2024-05-24 Thread Liam.Jackson--- via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114561

--- Comment #11 from Liam Jackson  ---
Thank-you all for narrowing down and fixing this issue, and back-porting the
fix to older compilers. It is much appreciated.