CppCoreGuidelines icon indicating copy to clipboard operation
CppCoreGuidelines copied to clipboard

Does R.15 need to be said?

Open tituswinters opened this issue 11 years ago • 2 comments

R.15 is a little unclear to me. It's talking about overloading operators new/delete (a rare, and non-novice operation) but seems really obvious. Is there a history of people getting this wrong leading to this suggestion? I'd think in practice that anyone capable of writing an overload for new would know that they have to do the associated delete, no?

tituswinters avatar Dec 01 '15 20:12 tituswinters

On the one hand, I don’t think I needed to be told this the first time I overloaded operator new. On the other hand, I am very grateful for such explicit guidelines whenever I venture beyond my confort zone.

More importantly, I’ve worked with codebases with such issues. This is something I’d like static analysis to check.

On balance, I am in favor of this guideline.

fisherro avatar Dec 02 '15 22:12 fisherro

@fisherro - If people have real experience with failures on this, then I retract my concern. (I'm also, as always, surprised and terrified by programmers.)

I think there's some editorial work that could be done to make the whole thing a bit clearer if it's being kept. I'll write up something to (hopefully) clarify if Bjarne is amenable to that.

tituswinters avatar Dec 02 '15 22:12 tituswinters