Skip to content
Snippets Groups Projects
Commit 53283c32 authored by Marek Polacek's avatar Marek Polacek
Browse files

c++: ICE with enum and conversion fn in template [PR115657]

Here we initialize an enumerator with a class prvalue with a conversion
function.  When we fold it in build_enumerator, we create a TARGET_EXPR
for the object, and subsequently crash in tsubst_expr, which should not
see such a code.

Normally, we fix similar problems by using an IMPLICIT_CONV_EXPR but here
I may get away with not using the result of fold_non_dependent_expr unless
the result is a constant.  A TARGET_EXPR is not constant.

	PR c++/115657

gcc/cp/ChangeLog:

	* decl.cc (build_enumerator): Call maybe_fold_non_dependent_expr
	instead of fold_non_dependent_expr.

gcc/testsuite/ChangeLog:

	* g++.dg/cpp1y/constexpr-recursion2.C: New test.
	* g++.dg/template/conv21.C: New test.
parent 8191f150
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