-
- Downloads
Fix the issue with the temporary variable lifetime reported in PR#93006
The issue is as follows: If one omits the ; of a given statement at the prompt we attach in the AST a templated function which prints out the value. The function looks like for int p = 12 PrintValue((llvm::raw_ostream *)22345600UL, (clang::Expr *)23270416UL, (clang::ASTContext *)22594960UL, p); We manually get the expression and put it as a last argument of the PrintValue That is safe when we have storage of p. I.e p is an lvalue. However we might have: gCling->createUniqueName(), which returns std::string That is an rvalue, which doesn't have storage and its lifetime lasts until the end of the current statement. However if we attach it to the PrintValue we have to extend the lifetime of the argument to last until the new end of statement. Otherwise the argument will be destroyed before we manage to print it out. What we do in that case is move the expression annotating the termination of the temporary up as root expression of PrintValue call. Attach a regression test for the reported problem git-svn-id: http://root.cern.ch/svn/root/trunk@43526 27541ba8-7e3a-0410-8455-c3a389f83636
Please register or sign in to comment