New user self-registration is disabled due to spam. Please email eigen-core-team @ if you need an account.
Before reporting a bug, please make sure that your Eigen version is up-to-date!

Bug 1074

Summary: Forbid the creation of PlainObjectBase object
Product: Eigen Reporter: Gael Guennebaud <gael.guennebaud>
Component: Core - generalAssignee: Nobody <eigen.nobody>
Severity: API Change CC: chtz, gael.guennebaud, jacob.benoit.1, nathan.yonkee
Priority: Normal    
Version: 3.3 (current stable)   
Hardware: All   
OS: All   
Bug Depends on:    
Bug Blocks: 558    

Description Gael Guennebaud 2015-09-28 14:00:31 UTC
It is currently possible to directly create PlainObjectBase<Derived> objects, which is not very good practice as this class has been thought as an abstract base class.

So what about disabling this possibility by making all PlainObjectBase<Derived> private, and making Derived a friend class of PlainObjectBase<Derived>?

See also the following thread for some weird usages of PlainObjectBase<Derived>:
Comment 1 Christoph Hertzberg 2015-09-28 14:54:47 UTC
I also see no legit use of directly creating a PlainObjectBase<> (nor any other ...Base<>-object -- which in many cases would be an empty object, which behaves as if it contained data).
To implement this, wouldn't it be sufficient to make all constructors (and destructors, if needed) protected? Of course, this would leave the possibility to inherit 

  class WeirdClass : PlainObjectBase<SomeOtherClass> { ... };

but we can't avoid every possibility to shoot oneself in the foot ...
Comment 2 Gael Guennebaud 2015-09-28 15:04:43 UTC
yes, making them protected is definitely enough!
Comment 3 Nathan 2015-10-04 17:23:46 UTC
What about making the destructor of PlainObjectBase<typename> a pure virtual function? This would need only two additional lines of code and no changes to any of the derived classes.
Comment 4 Christoph Hertzberg 2015-12-08 17:40:26 UTC
We use pure static polymorphism in Eigen (no virtual functions).
A pure virtual destructor is actually rather complicated (I was surprised that it is even possible ...)
Comment 5 Gael Guennebaud 2015-12-09 20:37:32 UTC