Skip to content

Commit

Permalink
DynamicLibraryManager::loadLibrary if the parameter resolve is false
Browse files Browse the repository at this point in the history
The error occurs only when `loadLibrary()` is called with the argument `resolved = false`.
A const string reference is not possible here because a temporary copy of
lResolved would be referenced. The return type of libStem.str() has the
value type prvalue. Therefore, lResolved requires the same type and the
compiler inserts a copy constructor to satisfy this. For more details
see rule 3.3.1 here:
https://en.cppreference.com/w/cpp/language/operator_other#Conditional_operator
  • Loading branch information
SimeonEhrig authored and vgvassilev committed May 19, 2022
1 parent 5c35604 commit feb43fd
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions interpreter/cling/lib/Interpreter/DynamicLibraryManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -355,11 +355,12 @@ namespace cling {
(resolved ? "resolved" : "not-resolved") << "\n";
}

std::string lResolved;
const std::string& canonicalLoadedLib = resolved ? libStem.str() : lResolved;
if (!resolved) {
lResolved = lookupLibrary(libStem);
if (lResolved.empty())
std::string canonicalLoadedLib;
if (resolved) {
canonicalLoadedLib = libStem.str();
} else {
canonicalLoadedLib = lookupLibrary(libStem);
if (canonicalLoadedLib.empty())
return kLoadLibNotFound;
}

Expand Down

0 comments on commit feb43fd

Please sign in to comment.