<html>
    <head>
      <base href="https://bugs.llvm.org/">
    </head>
    <body><span class="vcard"><a class="email" href="mailto:Fedor.Sergeev@oracle.com" title="Fedor Sergeev <Fedor.Sergeev@oracle.com>"> <span class="fn">Fedor Sergeev</span></a>
</span> changed
          <a class="bz_bug_link 
          bz_status_RESOLVED  bz_closed"
   title="RESOLVED INVALID - InitPreprocessor.cpp:InitializePredefinedMacros constructs a version string from out-of-scope memory"
   href="https://bugs.llvm.org/show_bug.cgi?id=24684">bug 24684</a>
          <br>
             <table border="1" cellspacing="0" cellpadding="8">
          <tr>
            <th>What</th>
            <th>Removed</th>
            <th>Added</th>
          </tr>

         <tr>
           <td style="text-align:right;">Resolution</td>
           <td>---
           </td>
           <td>INVALID
           </td>
         </tr>

         <tr>
           <td style="text-align:right;">Status</td>
           <td>NEW
           </td>
           <td>RESOLVED
           </td>
         </tr>

         <tr>
           <td style="text-align:right;">CC</td>
           <td>
                
           </td>
           <td>Fedor.Sergeev@oracle.com
           </td>
         </tr></table>
      <p>
        <div>
            <b><a class="bz_bug_link 
          bz_status_RESOLVED  bz_closed"
   title="RESOLVED INVALID - InitPreprocessor.cpp:InitializePredefinedMacros constructs a version string from out-of-scope memory"
   href="https://bugs.llvm.org/show_bug.cgi?id=24684#c6">Comment # 6</a>
              on <a class="bz_bug_link 
          bz_status_RESOLVED  bz_closed"
   title="RESOLVED INVALID - InitPreprocessor.cpp:InitializePredefinedMacros constructs a version string from out-of-scope memory"
   href="https://bugs.llvm.org/show_bug.cgi?id=24684">bug 24684</a>
              from <span class="vcard"><a class="email" href="mailto:Fedor.Sergeev@oracle.com" title="Fedor Sergeev <Fedor.Sergeev@oracle.com>"> <span class="fn">Fedor Sergeev</span></a>
</span></b>
        <pre>OP appears to be confused by Builder.defineMacro functionality.

<span class="quote">> It stringifies it, but by the time it's stringified, the std::string from
> getClangFullRepositoryVersion() has gone out of scope.</span >

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.</pre>
        </div>
      </p>


      <hr>
      <span>You are receiving this mail because:</span>

      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>