This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/80290] [6/7/8/9 Regression] g++ uses unreasonable amount of memory compiling nested string maps
- From: "jason at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Wed, 27 Jun 2018 03:00:12 +0000
- Subject: [Bug c++/80290] [6/7/8/9 Regression] g++ uses unreasonable amount of memory compiling nested string maps
- Auto-submitted: auto-generated
- References: <bug-80290-4@http.gcc.gnu.org/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80290
--- Comment #29 from Jason Merrill <jason at gcc dot gnu.org> ---
Author: jason
Date: Wed Jun 27 02:59:38 2018
New Revision: 262172
URL: https://gcc.gnu.org/viewcvs?rev=262172&root=gcc&view=rev
Log:
PR c++/80290 - memory-hog with std::pair.
* pt.c (fn_type_unification): Add convs parameter.
(check_non_deducible_conversion): Remember conversion.
(check_non_deducible_conversions): New. Do checks here.
(type_unification_real): Not here. Remove flags parm.
* call.c (add_function_candidate): Make convs a parameter.
Don't recalculate the conversion if it's already set.
(add_template_candidate_real): Allocate convs here.
(good_conversion, conv_flags): New.
When the std::pair constructors got more complex to handle, it aggravated a
preexisting algorithmic problem in template overload resolution:
As part of template argument deduction in a call, once we've deduced all
the template arguments we can but before we substitute them to form an
actual declaration, for any function parameters that don't involve template
parameters we need to check that it's possible to convert the argument to
the parameter type (wg21.link/cwg1391).
As a result, we end up calculating the conversion twice: once here, and
then again in add_function_candidate as part of normal overload resolution.
Normally this isn't a big deal, but when the argument is a multiply-nested
initializer list, doubling the conversion processing at each level leads to
combinatorial explosion.
The patch for trunk avoids the duplication by remembering the conversion we
calculate at deduction time and then reusing it in overload resolution
rather than calculating it again.
Modified:
trunk/gcc/cp/ChangeLog
trunk/gcc/cp/call.c
trunk/gcc/cp/class.c
trunk/gcc/cp/cp-tree.h
trunk/gcc/cp/pt.c