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
MQTT made easier...
by
avra
[
Today
at 05:03:13 pm]
Why free pascal suppress ...
by
nanobit
[
Today
at 04:35:40 pm]
Is there a way to emphasi...
by
cdbc
[
Today
at 04:17:43 pm]
RTL: export/import WriteL...
by
paule32
[
Today
at 04:15:30 pm]
Treeview: full-width back...
by
wp
[
Today
at 04:03:26 pm]
Deal or no Deal graphic
by
TBMan
[
Today
at 03:51:53 pm]
read keys from windows ko...
by
marcov
[
Today
at 03:49:22 pm]
my programs crash
by
jamie
[
Today
at 01:22:58 pm]
Custom self drawn compone...
by
cdbc
[
Today
at 12:50:10 pm]
IsNan
by
robert rozee
[
Today
at 12:07:43 pm]
Reading and writing AVIF ...
by
Boleeman
[
Today
at 12:01:52 pm]
Reading FLIF images in La...
by
Boleeman
[
Today
at 11:58:25 am]
FLIF and FUIF Formats (Fr...
by
Boleeman
[
Today
at 11:42:17 am]
efficiency problem
by
photor
[
Today
at 11:33:05 am]
Failed to connect to a si...
by
jcmontherock
[
Today
at 10:54:36 am]
making default event hand...
by
egsuh
[
Today
at 10:03:37 am]
TmemTable has not onCalcF...
by
egsuh
[
Today
at 08:46:27 am]
Simple mouse solution for...
by
Lauriet
[
Today
at 08:15:34 am]
Scrollbox, scrollbar Back...
by
ASerge
[
Today
at 08:14:46 am]
"extended" real type prec...
by
LV
[
Today
at 06:48:44 am]
FPC can't link screen_dem...
by
mccfrank
[
Today
at 12:06:32 am]
ThemeServices.DrawText in...
by
regs
[February 08, 2025, 11:25:01 pm]
Gradient with fcl-image
by
wp
[February 08, 2025, 10:46:18 pm]
using RunCommand to wrap ...
by
nomorelogic
[February 08, 2025, 10:39:37 pm]
ellipse ? off topic
by
BubikolRamios
[February 08, 2025, 10:15:18 pm]
« previous
next »
Print
Pages: [
1
]
Author
Topic: SetLength fall (Read 1002 times)
LemonParty
Full Member
Posts: 111
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: 649
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: 12030
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
Full Member
Posts: 111
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