Page MenuHomePhabricator

[Sema] Avoid using an invalid InsertPos
Needs ReviewPublic

Authored by Mordante on Jan 2 2020, 12:56 PM.

Details

Reviewers
lvoufo
rsmith
Summary

The function Sema::CheckVarTemplateId tries to find a template specialization. If that fails it gets an InsertPos where the specialization should be added in a FoldingSet. Then it tries to resolve dependant arguments. This may add an item to the same FoldingSet. If this happens the set may be resized, which invalidates InsertPos.

It would be possible to send a nullptr to the call to BuildVarTemplateInstantiation, but that changes the behavior and fixing that seemed quite intrusive. Therefore the InsertPos is determined again before making the call.

Fixes PR43221: Assertion failure in translation unit with exactly 1 less than a power of 2 (starting at 127) operator== overloads combined with at least one operator== template with a substitution failure

Diff Detail

Event Timeline

Mordante created this revision.Jan 2 2020, 12:56 PM

Unit tests: pass. 61175 tests passed, 0 failed and 729 were skipped.

clang-tidy: fail. Please fix clang-tidy findings.

clang-format: fail. Please format your changes with clang-format by running git-clang-format HEAD^ or applying this patch.

Build artifacts: diff.json, clang-tidy.txt, clang-format.patch, CMakeCache.txt, console-log.txt, test-results.xml

Friendly ping.