diff options
author | Stephen Kelly <steveire@gmail.com> | 2015-05-16 04:52:30 (GMT) |
---|---|---|
committer | Stephen Kelly <steveire@gmail.com> | 2015-05-16 04:54:31 (GMT) |
commit | 921d74d8559daf6fbef7d78e582029f6acb04f6e (patch) | |
tree | e0b586834f348b725380af104e5343a0181fc637 /Source | |
parent | 2e4ea0c055e01e10c8f459398f943b1b62c5c7bb (diff) | |
download | CMake-921d74d8559daf6fbef7d78e582029f6acb04f6e.zip CMake-921d74d8559daf6fbef7d78e582029f6acb04f6e.tar.gz CMake-921d74d8559daf6fbef7d78e582029f6acb04f6e.tar.bz2 |
AutoGen: Don't iterate over a container while populating it.
The InitializeAutogenTarget creates new targets and adds them to the
Targets container on the makefile. In this method, we have a reference
to that container and we are iterating over it. That happens to work
with hash_map, but it fails with undefined behavior when using the
std::unordered_map from libstdc++-4.9 (and likely others).
Diffstat (limited to 'Source')
-rw-r--r-- | Source/cmGlobalGenerator.cxx | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index 1c9c475..82023e4 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -1373,10 +1373,18 @@ void cmGlobalGenerator::CreateQtAutoGeneratorsTargets(AutogensType &autogens) { cmTargets& targets = this->LocalGenerators[i]->GetMakefile()->GetTargets(); + std::vector<std::string> targetNames; + targetNames.reserve(targets.size()); for(cmTargets::iterator ti = targets.begin(); ti != targets.end(); ++ti) { - cmTarget& target = ti->second; + targetNames.push_back(ti->second.GetName()); + } + for(std::vector<std::string>::iterator ti = targetNames.begin(); + ti != targetNames.end(); ++ti) + { + cmTarget& target = *this->LocalGenerators[i] + ->GetMakefile()->FindTarget(*ti, true); if(target.GetType() == cmTarget::EXECUTABLE || target.GetType() == cmTarget::STATIC_LIBRARY || target.GetType() == cmTarget::SHARED_LIBRARY || |