Nathaniel Smith schrieb: > 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?
This usage shows a problem: Musings on integer variables are not possible with the current system. What about a value storing musing variant? I certainly have use for it. > 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. The only way I know to make the compiler warn about this is to require a non const reference. (The usual way to require a non temporary argument IIRC). > 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... If we manage to copy the value once it is const this would work transparently (I don't know how to accomplish this, the STL algo variants e.g. decide by class inheritance, perhaps a similar way is possible). Is there a gcc internal function or a macro which tells whether an expression is a lvalue? Christof
signature.asc
Description: OpenPGP digital signature
_______________________________________________ Monotone-devel mailing list [email protected] http://lists.nongnu.org/mailman/listinfo/monotone-devel
