From 519a33f954fd71cb8b74053e168e23a1cb00d30b Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Fri, 14 Feb 2020 17:36:00 +0100 Subject: c++: Fix thinko in enum_min_precision [PR61414] When backporting the PR61414 fix to 8.4, I've noticed that the caching of prec is actually broken, as it would fail to actually store the computed precision into the hash_map's value and so next time we'd think the enum needs 0 bits. 2020-02-14 Jakub Jelinek PR c++/61414 * class.c (enum_min_precision): Change prec type from int to int &. * g++.dg/cpp0x/enum39.C: New test. --- gcc/cp/class.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'gcc/cp/class.c') diff --git a/gcc/cp/class.c b/gcc/cp/class.c index f9e46ca..a1fd1aa 100644 --- a/gcc/cp/class.c +++ b/gcc/cp/class.c @@ -3289,7 +3289,7 @@ enum_min_precision (tree type) enum_to_min_precision = hash_map::create_ggc (37); bool existed; - int prec = enum_to_min_precision->get_or_insert (type, &existed); + int &prec = enum_to_min_precision->get_or_insert (type, &existed); if (existed) return prec; -- cgit v1.1