Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion core/base/inc/TNamed.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class TNamed : public TObject {
TString fTitle; //object title

public:
TNamed(): fName(), fTitle() { }
TNamed(): fName(), fTitle() { } // NOLINT: not allowed to use = default because of TObject::kIsOnHeap detection, see ROOT-10300
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
TNamed(): fName(), fTitle() { } // NOLINT: not allowed to use = default because of TObject::kIsOnHeap detection, see ROOT-10300
TNamed() {} // NOLINT: not allowed to use = default. See note on \ref TObject

Maybe drop the other initializers (they should be handled implicitly, I hope)?
Maybe reference the just newly added docs instead of something somewhere else?

TNamed(const char *name, const char *title) : fName(name), fTitle(title) { }
TNamed(const TString &name, const TString &title) : fName(name), fTitle(title) { }
TNamed(const TNamed &named);
Expand Down
12 changes: 12 additions & 0 deletions core/base/src/TObject.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,18 @@ ROOT collection classes.
TObject's bits can be used as flags, bits 0 - 13 and 24-31 are
reserved as global bits while bits 14 - 23 can be used in different
class hierarchies (watch out for overlaps).

\Note
Class inheriting directly or indirectly from TObject should not use
`= default` for any of the constructors.
The default implementation for a constructor can sometime do 'more' than we
expect (and still being standard compliant). On some platforms it will reset
all the data member of the class including its base class's member before the
actual execution of the base class constructor.
`TObject`'s implementation of the `IsOnHeap` bit requires the memory occupied
by `TObject::fUniqueID` to *not* be reset between the execution of `TObject::operator new`
and the `TObject` constructor (Finding the magic pattern there is how we can determine
that the object was allocated on the heap).
*/

#include <cstring>
Expand Down
Loading