[Date Prev][Date Next][Thread Prev][Thread Next][Author Index][Date Index][Thread Index]

another thing to avoid



Another one for xlint to catch:
	DerivedClass::DerivedClass (ArgType * arg)
		: BaseClass (::function(arg)) {
	  ...
	}
If function(arg) allocates any storage, the object under construction may
vanish during garbage collection.  It would not matter here if the
DerivedClass constructor had a saveThis strong pointer since its scope
will not have been entered, so nothing is pointing to the new object.
The arguments for BaseClass may only be trivial, such as constants or
unprocessed pointers.