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
How to forward a Class in...
by
Hartmut
[
Today
at 07:41:31 pm]
Additional Filedialog opt...
by
Hansaplast
[
Today
at 07:39:28 pm]
Linked List Using Two Cla...
by
cdbc
[
Today
at 06:34:17 pm]
set zero values not to b...
by
wp
[
Today
at 05:58:41 pm]
What was your first compu...
by
rvk
[
Today
at 05:57:06 pm]
Fast Canvas Library V1.05...
by
Gigatron
[
Today
at 05:15:06 pm]
solution for installing F...
by
Cascade
[
Today
at 04:16:40 pm]
Locate current record aft...
by
1HuntnMan
[
Today
at 03:52:59 pm]
StrToDateTime problems
by
cdbc
[
Today
at 03:10:28 pm]
Drag and Drop Files; onDr...
by
Hansaplast
[
Today
at 02:40:25 pm]
How to set the Excel cell...
by
wp
[
Today
at 02:10:13 pm]
RPNCalc in Lazarus
by
Thaddy
[
Today
at 01:31:40 pm]
Fantasy Worldbuilder; Pro...
by
Dzandaa
[
Today
at 12:39:06 pm]
[SOLVED] Transparent back...
by
wp
[
Today
at 11:19:10 am]
Why does FPC behave this ...
by
Thaddy
[
Today
at 10:39:31 am]
Parametrized Access SQL Q...
by
Zvoni
[
Today
at 09:45:53 am]
BS PanelTrans - transform...
by
Xenno
[
Today
at 05:54:55 am]
PngDrop: Reduce the size ...
by
ALLIGATOR
[
Today
at 04:05:04 am]
RTTIPropertyGrid expand
by
jamie
[
Today
at 03:17:43 am]
Sum GNU Anti Reversi 8x8 ...
by
Boleeman
[
Today
at 12:42:53 am]
Picture Process with BGRA...
by
circular
[January 12, 2026, 08:05:53 pm]
[SOLVED] Average color
by
LeP
[January 12, 2026, 06:51:24 pm]
HELP Why the WriteRowHeig...
by
wp
[January 12, 2026, 06:22:24 pm]
building a Calculator usi...
by
Dzandaa
[January 12, 2026, 03:51:20 pm]
How can Lazarus implement...
by
Tommi
[January 12, 2026, 03:46:47 pm]
« previous
next »
Print
Pages: [
1
]
Author
Topic: SetLength fall (Read 1268 times)
LemonParty
Sr. Member
Posts: 393
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: 12592
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: 393
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