https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90110

Florian Weimer <fw at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |fw at gcc dot gnu.org

--- Comment #8 from Florian Weimer <fw at gcc dot gnu.org> ---
(In reply to Ian Lance Taylor from comment #7)
> > What is the condition i > 0x7fffffff for?  Shouldn't that test val instead?
> 
> Yes, it certainly should.  Thanks.  It's not the problem here, but should be
> fixed.
> 
> > Just a wild guess - does this->body_.substr(start, i - start).c_str() 
> really live until after strtol has completed?
> 
> I *think* it should be OK.  The rule in C++ is that temporary objects are
> destroyed after the full expression that lexically contains the point at
> which they are created has been evaluated.  In this case the full expression
> is the call to strtol, so the temporary object created by the call to substr
> should live until the call to strtol is complete.

I think the *end != '\0' check is the problem here.  The temporary object is
gone at that point.

Reply via email to