[llvm-bugs] [Bug 24684] InitPreprocessor.cpp:InitializePredefinedMacros constructs a version string from out-of-scope memory

via llvm-bugs llvm-bugs at lists.llvm.org
Mon May 29 15:38:46 PDT 2017


https://bugs.llvm.org/show_bug.cgi?id=24684

Fedor Sergeev <Fedor.Sergeev at oracle.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |INVALID
             Status|NEW                         |RESOLVED
                 CC|                            |Fedor.Sergeev at oracle.com

--- Comment #6 from Fedor Sergeev <Fedor.Sergeev at oracle.com> ---
OP appears to be confused by Builder.defineMacro functionality.

> It stringifies it, but by the time it's stringified, the std::string from
> getClangFullRepositoryVersion() has gone out of scope.

defineMacro takes a string (well, Twine) argument and pushes it into the 'Out'
stream (which is by itself is a stream on a string buffer). This argument needs
to be alive only for the duration of defineMacro and not any longer.

And for sure, getClangFullRepositoryVersion() return result temporary
std::string leaves till the end of the full expression - which is a function
call to defineMacro in this case. Hence it lives just fine at least till the
end of defineMacro.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20170529/9a8be7a6/attachment.html>


More information about the llvm-bugs mailing list