monotone-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Monotone-devel] MM with temporaries


From: Nathaniel Smith
Subject: [Monotone-devel] MM with temporaries
Date: Thu, 22 Sep 2005 12:22:05 -0700
User-agent: Mutt/1.5.9i

I noticed .cvssync got a few lines like:
    MM(boost::lexical_cast<std::string>(i->time));
recently.  I'm pretty sure these can't possibly work?

MM() ends up passing its argument to Musing(), which takes a const
reference argument and stashes it in a member variable const
reference.  Then, if an assertion triggers, it prints out the value of
that member variable.  In this case, it seems that will point to a
already-deleted temporary, and we'll crash or something...

Distressingly, the compiler gives no warning or anything for this.

Anyone know how a way to get the compiler to stop (or a least warn) on
such things, or alternatively how to make them actually work?  We
don't want to just unconditionally store a value copy instead of a
reference, because MM() needs to be very cheap when assertions are not
hit, and this would make it very slow...

-- Nathaniel

-- 
"If you can explain how you do something, then you're very very bad at it."
  -- John Hopfield




reply via email to

[Prev in Thread] Current Thread [Next in Thread]