]> git.ipfire.org Git - thirdparty/gcc.git/commit
PR c++/80290 - memory-hog with std::pair.
authorjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 27 Jun 2018 02:59:38 +0000 (02:59 +0000)
committerjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 27 Jun 2018 02:59:38 +0000 (02:59 +0000)
commit070c395b755448b4bd4bb31c068fabaa166c514c
tree059a3a0d5a3e138552dc289f6a8a57827ababb92
parenta2fa87687ed5a19db7b6ed212b547238ad1a913b
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.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@262172 138bc75d-0d04-0410-961f-82ee72b054a4
gcc/cp/ChangeLog
gcc/cp/call.c
gcc/cp/class.c
gcc/cp/cp-tree.h
gcc/cp/pt.c