Generic TList, where T is a dynamic array is not safe to use in Delphi 10 Seattle and Delphi 10.1 Berlin.

Generic TList, where T is a dynamic array is not safe to use in Delphi 10 Seattle and Delphi 10.1 Berlin.

See https://quality.embarcadero.com/browse/RSP-16511 "Crash in TListHelper.DoSetItemDynArray() due to wrong TypeInfo used to clear the old dynamic array"

See also http://stackoverflow.com/q/41047688/576719 "How to work around Delphi 10's bug with TList<_AnyDynamicArrays_>?" for more details.
https://quality.embarcadero.com/browse/RSP-16511

Comments

  1. Günther Schoch You probably put the Generic at the wrong place.

    I've made my Own TObjectList ...the Generic part is the smaller one and all the code that do not need to know that T is something else than a Class is in a TCustomObjectList class without Generic

    TObjectList = class(TCustomObjectList)
    end;

    it's probably better than

    TObjectList = class(TList)
    TList = TEnumerable

    where everything have to be duplicated

    Note that it's required because Delphi's TList do not know that it use classes in this case.

    ReplyDelete
  2. Paul TOTH thank you for the hint. We actually tried a lot different approaches. But the fact is that Delphi does bloat the code a lot more than e.g. C# for the same Generics. And as David Heffernan says the reason is within the missing proper support in the compiler/linker chain to reuse the common areas. But I assume this goes really deep deep into the compiler/linker design and missing runtime information e.g. for the debugger.

    ReplyDelete
  3. I know that a person without compiler source access hacked into the linker to do that step years ago - so it cannot be that hard to do it properly.

    ReplyDelete

Post a Comment