On this page
B6001: allocator without an initial value
Catalog status: active. Default severity: error. Stable name: uninitialised-allocator. Family: Ownership and finalization.
An allocator new T without a qualified expression creates an object of T initialised by default. Verada accepts it only when every part of such an object has a default value: access values (which start as null), records whose components all have default expressions (or are of such types), arrays of such components, and private types whose full view is one of these. Otherwise the new object would start with unknown values that nothing could ever initialise before they are read through other access values.
Example (Vada)
type Int_Access is access Integer;
P : Int_Access := new Integer; -- the integer has no valueExample (Varc)
type Int_Access = *Integer;
var p: Int_Access = new Integer; // the integer has no value
What to do (Vada)
Give the object its value in the allocator (new Integer'(0)), or add default expressions to the record type's components.
What to do (Varc)
Give the object its value in the allocator (new Integer(0)), or add default values to the struct type's fields.
Regression source and further reading
Complete regression example: source, command arguments and expected results. The fixture deliberately reproduces this diagnostic.
See ownership and finalization, the code index, and diagnostic interpretation for modes, replay, fix-its and JSON.