Skip to content

RFC: Assert validitiy of Object's inner values during construction

Adam Reichold requested to merge (removed):assert-object-inner into master

The first commit asserts validity of Object's inner values during constructor where constructor or destructor currently assume this.

Another approach would be to make the constructors/destructor safe to use with invalid values using explicit checks.

A sort of outlier here is objString which currently can hold nullptr since the constructor and destructor are safe w.r.t. this. And Object::takeString even produces instances in that state, but this method should probably be to leave a objDead instance behind and then the related constructor could assert validity as well?

The second commit is completely optional w.r.t. the above and tries to marginally improve the safety of Object by splitting out the anonymous into a separate POD type that is then used as a private subtype so that the existing code does not need to be changed, but it becomes possible to reliably set/clear to whole union without relying on ad-hoc knowledge on the largest field. Also the by now hopefully unnecessary macros are removed.

Merge request reports