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
Strange implicit string c...
by
nanobit
[
Today
at 03:49:40 pm]
visasession
by
MarkMLl
[
Today
at 03:34:17 pm]
"set of": order of elemen...
by
440bx
[
Today
at 03:23:58 pm]
how to change font.color ...
by
bbd666
[
Today
at 03:12:15 pm]
Tesseract for ocr
by
rvk
[
Today
at 02:26:31 pm]
UADE Library
by
Gigatron
[
Today
at 01:50:35 pm]
TOHLCChartSource
by
wp
[
Today
at 01:41:45 pm]
read keys from windows ko...
by
Bart
[
Today
at 01:32:16 pm]
my programs crash
by
turunk
[
Today
at 01:19:49 pm]
Unselect all rows in stri...
by
Jonny
[
Today
at 01:10:54 pm]
Is there a code formatter...
by
Zvoni
[
Today
at 12:56:12 pm]
using RunCommand to wrap ...
by
MarkMLl
[
Today
at 12:14:30 pm]
Treeview: full-width back...
by
d7_2_laz
[
Today
at 09:57:32 am]
how to read cheque micr l...
by
Packs
[
Today
at 08:58:27 am]
User Domain
by
TRon
[
Today
at 08:49:48 am]
Bug in the formula MATCH
by
veb86
[
Today
at 07:28:39 am]
Error, the IF function do...
by
veb86
[
Today
at 06:47:30 am]
Source Editor - Open Sour...
by
n7800
[
Today
at 05:13:12 am]
Form Positioning (Run & D...
by
Tony Stone
[
Today
at 03:28:03 am]
StrToInt not raising an e...
by
ALLIGATOR
[
Today
at 03:17:25 am]
[solved] Issues was wrong...
by
What I can do
[
Today
at 01:03:09 am]
Specialisation doesn't se...
by
nixbody
[
Today
at 12:38:49 am]
Please explain what is Po...
by
PascalDragon
[February 06, 2025, 11:03:56 pm]
Compile App Error
by
eldonfsr
[February 06, 2025, 10:03:23 pm]
ellipse ? off topic
by
d2010
[February 06, 2025, 09:10:42 pm]
« previous
next »
Print
Pages: [
1
]
Author
Topic: SetLength fall (Read 993 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: 12025
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