Skip to content
Snippets Groups Projects
Commit cd673437 authored by Jason Merrill's avatar Jason Merrill
Browse files

c++: ICE with <=> fallback [PR100367]

Here, when genericizing lexicographical_compare_three_way, we haven't yet
walked the operands, so (a == a) still sees ADDR_EXPR <a>, but this is after
we've changed the type of a to REFERENCE_TYPE.  When we try to fold (a == a)
by constexpr evaluation, the constexpr code doesn't understand trying to
take the address of a reference, and we end up crashing.

Fixed by avoiding constexpr evaluation in genericize_spaceship, by using
fold_build2 instead of build_new_op on scalar operands.  Class operands
should have been expanded during parsing.

	PR c++/100367
	PR c++/96299

gcc/cp/ChangeLog:

	* method.c (genericize_spaceship): Use fold_build2 for scalar
	operands.

gcc/testsuite/ChangeLog:

	* g++.dg/cpp2a/spaceship-fallback1.C: New test.
parent 9b50282b
No related branches found
No related tags found
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment