On 9/19/16 10:26 AM, Lodovico Giaretta wrote:
On Monday, 19 September 2016 at 14:22:16 UTC, Steven Schveighoffer wrote:
On 9/19/16 7:27 AM, Lodovico Giaretta wrote:

What I'd like to know: is this usage widespread? Should we forbid it for
the sake of security?

No. There is no security concern here. You are dereferencing a null
pointer, which is perfectly safe.

Ok, wrong wording. I meant "should we forbid it to avoid long hours of
debugging and unexpected behaviours? One uses emplace expecting that it
Just Works(TM), which is not true for nested things."

Maybe we can disable the emplace that will certainly cause a Null pointer segfault when used, and allow the copying version. But there may still be code that uses the struct without needing the context pointer, that would then be broken.

My opinion is just not to worry about it. We don't get much traffic here complaining of this issue, you may be the one hardest hit by it (and you likely won't have it happen any more).

For instance, we have way way more complaints of people using classes without allocating them, and that is a similar problem.

However, a sufficient warning in the docs is certainly in order, at least as long as we aren't going to forbid it.


Reply via email to