Patrick Palka 21fd62e5ca c++: constexpr std::construct_at on empty field [PR101663]
Here during constexpr evaluation of

  std::construct_at(&a._M_value)

we find ourselves in cxx_eval_store_expression where the target object
is 'a._M_value' and the initializer is {}.  Since _M_value is an empty
[[no_unique_address]] member we don't create a sub-CONSTRUCTOR for it,
so we end up in the early exit code path for empty stores with mismatched
types and trip over the assert therein

  gcc_assert (is_empty_class (TREE_TYPE (init)) && !lval);

because lval is true.  The reason it's true is because the INIT_EXPR in
question is the LHS of a COMPOUND_EXPR, and evaluation of the LHS is
always performed with lval=true (to indicate there's no lvalue-to-rvalue
conversion).

This patch makes the code path in question handle the lval=true case
appropriately rather than asserting.  In passing, it also consolidates
the duplicate implementations of std::construct_at/destroy_at in some
of the C++20 constexpr tests into a common header file.

	PR c++/101663

gcc/cp/ChangeLog:

	* constexpr.c (cxx_eval_store_expression): Handle the lval=true
	case in the early exit code path for empty stores with mismatched
	types.

gcc/testsuite/ChangeLog:

	* g++.dg/cpp2a/construct_at.h: New convenience header file that
	defines minimal implementations of std::construct_at/destroy_at,
	split out from ...
	* g++.dg/cpp2a/constexpr-new5.C: ... here.
	* g++.dg/cpp2a/constexpr-new6.C: Use the header.
	* g++.dg/cpp2a/constexpr-new14.C: Likewise.
	* g++.dg/cpp2a/constexpr-new20.C: New test.
2021-08-11 20:59:53 -04:00
2021-08-11 00:16:27 +00:00
2021-08-07 00:16:39 +00:00
2021-08-11 00:16:27 +00:00
2021-08-10 00:16:28 +00:00
2021-08-12 00:16:28 +00:00
2021-08-12 00:16:28 +00:00
2021-08-10 00:16:28 +00:00

This directory contains the GNU Compiler Collection (GCC).

The GNU Compiler Collection is free software.  See the files whose
names start with COPYING for copying permission.  The manuals, and
some of the runtime libraries, are under different terms; see the
individual source files for details.

The directory INSTALL contains copies of the installation information
as HTML and plain text.  The source of this information is
gcc/doc/install.texi.  The installation information includes details
of what is included in the GCC sources and what files GCC installs.

See the file gcc/doc/gcc.texi (together with other files that it
includes) for usage and porting information.  An online readable
version of the manual is in the files gcc/doc/gcc.info*.

See http://gcc.gnu.org/bugs/ for how to report bugs usefully.

Copyright years on GCC source files may be listed using range
notation, e.g., 1987-2012, indicating that every year in the range,
inclusive, is a copyrightable year that could otherwise be listed
individually.
Description
No description provided
Readme 3.1 GiB
Languages
C 48%
Ada 18.3%
C++ 14.1%
Go 7%
GCC Machine Description 4.6%
Other 7.7%