Lazarus
Home
Help
TinyPortal
Search
Login
Register
Lazarus
»
Forum
»
Free Pascal
»
Beginners
(Moderators:
FPK
,
Tomas Hajny
) »
Generic function specialization compilation error
Free Pascal
Website
Downloads
Wiki
Documentation
Bugtracker
Mailing List
Lazarus
Website
Downloads (Laz+FPC)
Packages (OPM)
FAQ
Wiki
Documentation (RTL/FCL/LCL)
Bugtracker
CCR Bugs
GIT
Mailing List
Other languages
Foundation
Website
Useful Wiki Links
Project Roadmap
Getting the Source
Screenshots
How to use the forum
About donations (wiki)
Bookstore
Computer Math and Games in Pascal
(preview)
Lazarus Handbook
Search
Advanced search
Recent
What is a status of fpGUI...
by
Fred vS
[
Today
at 02:46:09 am]
Artificial intelligence
by
zeljko
[
Today
at 01:46:06 am]
Spaces are allowed here ?
by
440bx
[
Today
at 12:59:39 am]
SDL2 image rotation Probl...
by
TRon
[
Today
at 12:39:30 am]
A Tip for beginners
by
dbannon
[January 18, 2025, 11:30:59 pm]
Width of Project-Close D...
by
Wilko500
[January 18, 2025, 11:08:12 pm]
Looking For Lazarus Tutor...
by
cdbc
[January 18, 2025, 10:32:29 pm]
Fatal: Cannot find Contro...
by
Soner
[January 18, 2025, 09:58:44 pm]
Restoring minimized scree...
by
Soner
[January 18, 2025, 09:41:16 pm]
[SOLVED] SetPart ?
by
BubikolRamios
[January 18, 2025, 08:51:31 pm]
[SOLVED] Operators overri...
by
ackarwow
[January 18, 2025, 07:55:54 pm]
Programs writing programs...
by
MarkMLl
[January 18, 2025, 07:50:40 pm]
How to add new methods to...
by
jmpessoa
[January 18, 2025, 07:27:22 pm]
FPC 3.2.4, naming suggest...
by
ALLIGATOR
[January 18, 2025, 07:16:55 pm]
Preparing FPC 3.2.4, poin...
by
Fred vS
[January 18, 2025, 06:09:48 pm]
TSelectDirectoryDialog do...
by
krzynio
[January 18, 2025, 05:57:40 pm]
Iterator on non-existing ...
by
PascalDragon
[January 18, 2025, 05:08:52 pm]
const declaration
by
PascalDragon
[January 18, 2025, 05:05:55 pm]
How to avoid copying
by
PascalDragon
[January 18, 2025, 05:02:08 pm]
Nested declarations insid...
by
PascalDragon
[January 18, 2025, 04:57:51 pm]
TImage colors incorrect
by
Jonny
[January 18, 2025, 04:17:53 pm]
An interprocess network?
by
cdbc
[January 18, 2025, 03:10:31 pm]
INET TLUDPcomponent for i...
by
cdbc
[January 18, 2025, 03:08:38 pm]
Bug in the formula MATCH,...
by
veb86
[January 18, 2025, 02:40:23 pm]
Bug in the formula MATCH
by
veb86
[January 18, 2025, 02:21:09 pm]
« previous
next »
Print
Pages: [
1
]
Author
Topic: Generic function specialization compilation error (Read 513 times)
Laurent92
Newbie
Posts: 1
Generic function specialization compilation error
«
on:
November 27, 2024, 03:15:53 pm »
Hello,
I got this compilation error while experimenting with generic classes and functions and I have no idea what could have caused it.
Code: Text
[Select]
[+]
[-]
Free Pascal Compiler version 3.2.2 [2021/05/16] for aarch64
Copyright (c) 1993-2021 by Florian Klaempfl and others
Target OS: Darwin for AArch64
Compiling main.pas
fgl.pp(1668,8) Note: Call to subroutine "function TFPGMap<System.ShortString,System.Pointer>.IndexOf(const AKey:ShortString):LongInt;" marked as inline is not inlined
main.pas(44,1) Fatal: Internal error 2002071001
Fatal: Compilation aborted
Error: /usr/local/bin/ppca64 returned an error exitcode
Is this a bug of the compiler (should I open an issue on GitLab?) or is it simply not possible to do that with Objet Pascal?
Code: Pascal
[Select]
[+]
[-]
program
main
;
uses
TypInfo
,
FGL
;
type
TIndex
=
0
..
99
;
TGenericObjects
=
specialize TFPGMap<ShortString
,
Pointer>
;
generic TGenericObject<T>
=
class
(
TObject
)
private
FList
:
array
[
TIndex
]
of
T
;
public
procedure
Add
(
AIndex
:
TIndex
;
AElement
:
T
)
;
end
;
TGenericObjectFactory
=
class
(
TObject
)
public
generic
function
GetGenericObject<T>
:
specialize TGenericObject<T>
;
generic
procedure
Add<T>
(
AIndex
:
TIndex
;
AElement
:
T
)
;
private
FGenericObjects
:
TGenericObjects
;
end
;
generic
function
TGenericObjectFactory
.
GetGenericObject
<T>
:
specialize TGenericObject<T>
;
var
GenericObjectType
:
PTypeInfo
;
begin
GenericObjectType
:
=
TypeInfo
(
T
)
;
Result
:
=
specialize TGenericObject<T>
(
FGenericObjects
[
GenericObjectType
^
.
Name
]
^
)
;
end
;
generic
procedure
TGenericObjectFactory
.
Add
<T>
(
AIndex
:
TIndex
;
AElement
:
T
)
;
var
GenericObject
:
specialize TGenericObject<T>
;
begin
GenericObject
:
=
specialize GetGenericObject<T>
;
// <-- this line causes the bug
GenericObject
.
Add
(
AIndex
,
AElement
)
;
end
;
procedure
TGenericObject
.
Add
(
AIndex
:
TIndex
;
AElement
:
T
)
;
begin
FList
[
Aindex
]
:
=
AElement
;
end
;
begin
end
.
Logged
Bart
Hero Member
Posts: 5497
Re: Generic function specialization compilation error
«
Reply #1 on:
November 27, 2024, 03:21:28 pm »
No internal error using fpc main, so probably fixed.
Now someone should test fpc 3.2 fixes branch.
Bart
Logged
TRon
Hero Member
Posts: 3787
Re: Generic function specialization compilation error
«
Reply #2 on:
November 27, 2024, 04:02:21 pm »
Quote from: Bart on November 27, 2024, 03:21:28 pm
Now someone should test fpc 3.2 fixes branch.
No issues with fixes 3.2 but tested on x86_64 only.
Logged
I do not have to remember anything anymore thanks to total-recall.
Print
Pages: [
1
]
« previous
next »
Lazarus
»
Forum
»
Free Pascal
»
Beginners
(Moderators:
FPK
,
Tomas Hajny
) »
Generic function specialization compilation error
TinyPortal
© 2005-2018