Skip to content

Commit

Permalink
Merge pull request cms-sw#111 from wmtan/RemoveDangerousConstCast
Browse files Browse the repository at this point in the history
Avoid use of const_cast
  • Loading branch information
ktf committed Jul 15, 2013
2 parents e04d7f6 + b4bdf11 commit 67ffabf
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions DataFormats/Streamer/src/StreamedProducts.cc
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,15 @@ namespace edm {
std::vector<BranchID> const* parents) :
desc_(&desc), present_(present), parents_(parents), prod_(const_cast<void*>(prod)), classRef_() {
if(present_ && prod == 0) {
const_cast<BranchDescription&>(desc).init();
std::string branchName = desc.branchName();
if(branchName.empty()) {
BranchDescription localCopy(desc);
localCopy.initBranchName();
branchName = localCopy.branchName();
}
throw edm::Exception(edm::errors::LogicError, "StreamedProduct::StreamedProduct\n")
<< "A product with a status of 'present' is not actually present.\n"
<< "The branch name is " << desc.branchName() << "\n"
<< "The branch name is " << branchName << "\n"
<< "Contact a framework developer.\n";
}
}
Expand Down

0 comments on commit 67ffabf

Please sign in to comment.