Henrik Nordstrom wrote: > Hi Robert, > > can you (or someone else who groks C++ casts) please explain why this > happened? > > http://www.squid-cache.org/Versions/v3/3.0/changesets/10249.patch > > > store.cc:712 > > ((HttpHeader) pe->getReply()->header).putStr(HDR_VARY, vary.buf());
It's a temporary. pe->getReply()->head will get casted into the HttpHeader, used to call putStr(...), then its life is over, at which point the C++ implementation is free to destroy it at its leisure (some impl's do it after the end of the statement, some wait until the end of the function). Even if you'd said "HttpHeader HH = ...", it would still create a temporary, copy-construct the new HttpHeader, and then destroy the temporary. Nick Lewycky
