Lazarus
Home
Help
TinyPortal
Search
Login
Register
Lazarus
»
Forum
»
Programming
»
General
»
SetLength fall
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
Forum Rules
About donations (wiki)
Bookstore
Computer Math and Games in Pascal
(preview)
Lazarus Handbook
Search
Advanced search
Recent
Need help converting a C+...
by
jamie
[
Today
at 11:07:36 pm]
Compiled package
by
PascalDragon
[
Today
at 11:04:05 pm]
Possible LMAX Disruptor (...
by
PascalDragon
[
Today
at 11:00:36 pm]
append new record to arra...
by
PascalDragon
[
Today
at 10:53:41 pm]
[Solved] Need help with c...
by
PascalDragon
[
Today
at 10:42:40 pm]
a bug about FPC spurce
by
Bart
[
Today
at 10:35:16 pm]
I cannot save an unit on ...
by
wp
[
Today
at 10:30:47 pm]
[SOLVED] progress dialog ...
by
Phoenix
[
Today
at 10:21:09 pm]
Problem with TSQLQuery
by
rvk
[
Today
at 10:10:51 pm]
Possible bug in Lazarus 4...
by
Alex.Machado
[
Today
at 08:29:05 pm]
IDE Colors compiled with ...
by
begend
[
Today
at 07:41:23 pm]
Mapping Images Like Odome...
by
circular
[
Today
at 06:41:24 pm]
Convert string with Key-V...
by
Bart
[
Today
at 06:37:32 pm]
fpcupdeluxe gets error wh...
by
Thaddy
[
Today
at 04:45:43 pm]
Lazarus Bugfix Release 4...
by
BrunoK
[
Today
at 03:19:18 pm]
Ho Ho Ho IntraWeb in Laza...
by
Thaddy
[
Today
at 09:58:28 am]
Lazarus is not working
by
cdbc
[
Today
at 09:51:39 am]
Clipboard Formats
by
AlexTP
[
Today
at 08:51:22 am]
TurboBird for FireBird 5
by
maurog
[
Today
at 04:45:18 am]
TurboBird IBX
by
maurog
[
Today
at 04:41:20 am]
How to get at files that ...
by
Martin_fr
[
Today
at 12:33:32 am]
make cycle fails on macOS...
by
Thausand
[December 07, 2025, 10:05:00 pm]
Matching video to form
by
Thausand
[December 07, 2025, 09:48:04 pm]
TTagEdit Component 1.2
by
JD
[December 07, 2025, 08:02:41 pm]
[SOLVED] Form OnTop not w...
by
Pe3s
[December 07, 2025, 07:32:12 pm]
« previous
next »
Print
Pages: [
1
]
Author
Topic: SetLength fall (Read 1246 times)
LemonParty
Sr. Member
Posts: 391
SetLength fall
«
on:
December 04, 2024, 02:58:34 pm »
Can anyone explain why next program falling at line
SetLength(B, 10000);
?
Logged
Lazarus v. 4.99. FPC v. 3.3.1. Windows 11
Fibonacci
Hero Member
Posts: 788
Internal Error Hunter
Re: SetLength fall
«
Reply #1 on:
December 04, 2024, 03:05:29 pm »
Its failing at this line:
Code: Pascal
[Select]
[+]
[-]
procedure
Go
;
var
Buf
:
TMnistImg
;
i
,
j
,
k
:
Integer
;
begin
SetLength
(
A
,
60000
)
;
for
k
:
=
1
to
60000
do
begin
for
i
:
=
1
to
28
do
for
j
:
=
1
to
28
do
begin
if
IsNan
(
Buf
[
j
,
i
]
)
then
A
[
k
]
[
i
,
j
]
:
=
0.0
else
A
[
k
]
[
i
,
j
]
:
=
Buf
[
j
,
i
]
/
255
;
end
;
end
;
SetLength
(
B
,
10000
)
;
end
;
Fix:
Code: Pascal
[Select]
[+]
[-]
for
k
:
=
0
to
high
(
A
)
do
begin
Logged
marcov
Administrator
Hero Member
Posts: 12563
FPC developer.
Re: SetLength fall
«
Reply #2 on:
December 04, 2024, 03:08:59 pm »
Probably it is accessing A[60000] just before that line. Debugger sometimes stop on the line after the problem.
Setlength(N) creates elements from 0 to N-1 not 1 to N
Logged
LemonParty
Sr. Member
Posts: 391
Re: SetLength fall
«
Reply #3 on:
December 04, 2024, 03:29:35 pm »
Thank you. I had to watch carefully. I knew about 0-base arrays.
Logged
Lazarus v. 4.99. FPC v. 3.3.1. Windows 11
Print
Pages: [
1
]
« previous
next »
Lazarus
»
Forum
»
Programming
»
General
»
SetLength fall
TinyPortal
© 2005-2018