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
About donations (wiki)
Bookstore
Computer Math and Games in Pascal
(preview)
Lazarus Handbook
Search
Advanced search
Recent
UK's Online Safety Act
by
Joanna from IRC
[
Today
at 03:53:43 pm]
Exclude Jedi Code Formatt...
by
BrunoK
[
Today
at 03:36:23 pm]
Making sense of pparser, ...
by
JernejL
[
Today
at 03:16:26 pm]
[SOLVED] Application.Proc...
by
erol
[
Today
at 03:14:59 pm]
Looking For Lazarus Tutor...
by
d2010
[
Today
at 03:08:57 pm]
No access to the wiki
by
Marc
[
Today
at 02:52:43 pm]
Return nil/null of data t...
by
DragoRosso
[
Today
at 02:50:36 pm]
Generic methods inside a ...
by
Zoran
[
Today
at 01:38:26 pm]
OPC client with Lazarus
by
Truffaldino
[
Today
at 01:18:34 pm]
TFPHttpClient timeout err...
by
geraldholdsworth
[
Today
at 01:11:21 pm]
debugging code for te ACS...
by
dseligo
[
Today
at 12:57:05 pm]
Fpcupdeluxe
by
folkeu08
[
Today
at 12:38:08 pm]
Painting on a control - 3...
by
majolika
[
Today
at 10:56:33 am]
مشكلة في dbgrid
by
Gebo
[
Today
at 10:41:39 am]
مشكلة في التقارير
by
Gebo
[
Today
at 10:37:06 am]
TRichMemo: Popup menu not...
by
CM630
[
Today
at 09:57:53 am]
Getting format error load...
by
MISV
[
Today
at 08:42:52 am]
Compile on multiple distr...
by
dodgebros
[
Today
at 05:44:44 am]
SDL3 Headers for FPC
by
Guva
[
Today
at 04:05:01 am]
Does unit recompilation r...
by
Fred vS
[
Today
at 02:34:42 am]
Resolving procedure symbo...
by
TCH
[
Today
at 01:04:13 am]
Run ffmpeg via TProcess
by
TRon
[January 22, 2025, 10:52:55 pm]
Lazarus Bugfix Release 3....
by
Martin_fr
[January 22, 2025, 10:41:06 pm]
Lazarus Release Candidate...
by
zeljko
[January 22, 2025, 09:56:24 pm]
Minor Q: HowTo use 'Debug...
by
d7_2_laz
[January 22, 2025, 09:40:14 pm]
« previous
next »
Print
Pages: [
1
]
Author
Topic: SetLength fall (Read 680 times)
LemonParty
Jr. Member
Posts: 98
SetLength fall
«
on:
December 04, 2024, 02:58:34 pm »
Can anyone explain why next program falling at line
SetLength(B, 10000);
?
Logged
Fibonacci
Hero Member
Posts: 647
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: 11998
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
Jr. Member
Posts: 98
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
Print
Pages: [
1
]
« previous
next »
Lazarus
»
Forum
»
Programming
»
General
»
SetLength fall
TinyPortal
© 2005-2018