View Issue Details

IDProjectCategoryView StatusLast Update
0035926FPCPackagespublic2019-08-09 10:32
ReporterOlegAssigned To 
PrioritynormalSeverityminorReproducibilityalways
Status newResolutionopen 
Platformi386, x86_64OSWin32, Win64OS VersionWindows 7, 10
Product Version3.3.1Product Buildr42488 
Target VersionFixed in Version 
Summary0035926: rtl-generics: The program crashes when using the classes inherited from the TOrdinalComparer<T, THashFactory>
DescriptionThe program crashes when calling methods GetHashCode, GetHashList and Equals classes TGOrdinalStringComparer<T, THashFactory> and TGOrdinalIStringComparer<T, THashFactory> - defined in the Generics.Defaults module.

Reason:
1) at the initialization stage of the program (in fpc_initializeunits), the class constructor TOrdinalComparer<T, THashFactory>.Create is called before the call of the class constructors of the THashService<T> and TExtendedHashService<T>. Therefore, the fields FEqualityComparer and FExtendedEqualityComparer are initialized to nil.

2) also, in the class constructor TOrdinalComparer<T, THashFactory>.Create, check is performed THashFactory.InheritsFrom(TExtendedHashService), while it is further assumed that the type THashFactory is an inheritor of the TExtendedHashFactory or THashFactory classes.
Steps To ReproduceTest program: test_GCL.lpr
Additional InformationThe problem is solved either by taking the definitions of the TOrdinalComparer<T, THashFactory> class and his childrens classes into a separate module, or by replacing the constructors with the initialization procedures that are called if necessary. The latter allows you to get rid of the call to the constructors of unused classes at the initialization stage of the program.
Tagsgenerics
Fixed in Revision
FPCOldBugId
FPCTarget
Attached Files

Activities

Oleg

2019-08-04 06:49

reporter  

test_GCL.lpr (5,936 bytes)

Issue History

Date Modified Username Field Change
2019-08-04 06:49 Oleg New Issue
2019-08-04 06:49 Oleg File Added: test_GCL.lpr
2019-08-09 10:32 Sven Barth Tag Attached: generics