rtl-generics constref->const change (69349104) breaks TList.IndexOf
Summary
We recently upgraded FPC 3.3.1 version used in our Docker (https://castle-engine.io/docker - it packages a few FPC versions) and noticed that one Castle Game Engine testcases started to fail.
Searching using TList.IndexOf
on a list of vectors (defined like TMyVector = packed array [0..1] of Single
) no longer works. Previously it worked, and did underneath a simple binary comparison of TMyVector
contents.
Testing, it seems that commit 69349104 broke it. With FPC at previous commit, 43f4904d , it is all OK. FPC 3.2.2, 3.2.0, and Delphi 11.0 also pass this test.
( Note: The change also broke compatibility, we had to adjust in CGE a few cases when we used virtual methods or callbacks, and previously they were using {$ifdef FPC}constref{$else}const{$endif}
. Now they need {$ifdef GENERICS_CONSTREF}constref{$else}const{$endif}
with GENERICS_CONSTREF
defined only for older FPC. But I only mention this fact for completeness. The change actually increases the Delphi compatibility so it is better to break now, but at least have future FPC more aligned with Delphi. )
System Information
Tested with FPC 3.3.1 compiled by fpcupdeluxe on Linux/x86_64.
Steps to reproduce
$ fpc test_generic_list_indexof.lpr
$ ./test_generic_list_indexof
Example Project
Relevant logs and/or screenshots
Fails with 69349104 :
$ fpc test_generic_list_indexof.lpr
Free Pascal Compiler version 3.3.1-12234-g693491048b [2022/12/23] for x86_64
Copyright (c) 1993-2022 by Florian Klaempfl and others
Target OS: Linux for x86-64
Compiling test_generic_list_indexof.lpr
generics.collections.pas(1279,20) Note: Call to subroutine "function TEnumerable<Program.TMyVector>.GetEnumerator:TEnumerator$1$crc0EBA89EB_crc1CEAE787;" marked as inline is not inlined
generics.collections.pas(150,52) Note: Private type "TCustomPointersEnumerator$2<PROGRAM.TMyVector,PROGRAM.TCustomList$1$crc0EBA89EB_crc1CEAE787.PT>.T" never used
Linking test_generic_list_indexof
98 lines compiled, 0.6 sec, 759936 bytes code, 434128 bytes data
2 note(s) issued
$ ./test_generic_list_indexof
An unhandled exception occurred at $00000000004273D1:
EAssertionFailed: Assertion failed (test_generic_list_indexof.lpr, line 65)
$00000000004273D1
Works OK with 43f4904d , parent of 69349104 .
$ fpc test_generic_list_indexof.lpr
Free Pascal Compiler version 3.3.1-12233-g43f4904d74 [2022/12/23] for x86_64
Copyright (c) 1993-2022 by Florian Klaempfl and others
Target OS: Linux for x86-64
Compiling test_generic_list_indexof.lpr
generics.collections.pas(1279,20) Note: Call to subroutine "function TEnumerable<Program.TMyVector>.GetEnumerator:TEnumerator$1$crc0EBA89EB_crc1CEAE787;" marked as inline is not inlined
generics.collections.pas(150,52) Note: Private type "TCustomPointersEnumerator$2<PROGRAM.TMyVector,PROGRAM.TCustomList$1$crc0EBA89EB_crc1CEAE787.PT>.T" never used
Linking test_generic_list_indexof
118 lines compiled, 0.6 sec, 759744 bytes code, 434128 bytes data
2 note(s) issued
$ ./test_generic_list_indexof