Lazarus
Home
Help
TinyPortal
Search
Login
Register
Lazarus
»
Forum
»
Programming
»
General
»
Overflow problem
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
Slow app start on M5 MacB...
by
pleumann
[
Today
at 09:30:46 am]
docking IDE
by
Paolo
[
Today
at 09:10:24 am]
[SOLVED] BitBtn Oddity
by
Petrus Vorster
[
Today
at 09:05:55 am]
Putting a new file on a w...
by
MarkMLl
[
Today
at 09:03:20 am]
Engineering Software from...
by
cdbc
[
Today
at 08:40:08 am]
Difference between @ and ...
by
paule32
[
Today
at 08:18:43 am]
Lazarus Bugfix Release 4....
by
papillon33
[
Today
at 08:15:45 am]
GTK3 is now the default w...
by
dbannon
[
Today
at 07:26:00 am]
KOL4 Beta available.
by
Fibonacci
[
Today
at 06:47:39 am]
Many recent books on Laza...
by
Khrys
[
Today
at 06:35:48 am]
Lazarus Main not building...
by
dsiders
[
Today
at 03:16:27 am]
Isn’t this funny?
by
n7800
[July 16, 2026, 11:57:09 pm]
Error when opening a proj...
by
Tomu
[July 16, 2026, 09:11:54 pm]
Is this safe, changing fr...
by
mas steindorff
[July 16, 2026, 08:46:31 pm]
TPeriodicTable
by
wp
[July 16, 2026, 08:00:38 pm]
Windows 2026_7 update and...
by
Martin_fr
[July 16, 2026, 07:46:38 pm]
try/except error
by
toby
[July 16, 2026, 06:55:42 pm]
How to connect to MariaDb...
by
Thaddy
[July 16, 2026, 05:51:17 pm]
Computers sure have come ...
by
Zvoni
[July 16, 2026, 03:36:38 pm]
KOL x64
by
Thaddy
[July 16, 2026, 02:06:48 pm]
Install new .deb over exi...
by
dbannon
[July 16, 2026, 01:45:27 pm]
FastCGI vs. CGI
by
egsuh
[July 16, 2026, 12:45:05 pm]
Solpage
by
munair
[July 15, 2026, 01:47:30 pm]
Need help with fphttpserv...
by
Thaddy
[July 15, 2026, 12:58:30 pm]
Freepascal
by
Thaddy
[July 15, 2026, 12:39:23 pm]
« previous
next »
Print
Pages: [
1
]
Author
Topic: Overflow problem (Read 180 times)
LemonParty
Hero Member
Posts: 557
Overflow problem
«
on:
July 05, 2026, 05:57:45 pm »
Hello.
Here is the simplified code:
Code: Pascal
[Select]
[+]
[-]
for
i
:
=
0
to
Length
(
S
)
div
BufSize
do
begin
k
:
=
Pred
(
Min
(
BufSize
,
SizeUInt
(
Length
(
S
)
-
i
*
BufSize
)
)
div
BitSizeOf
(
SizeUInt
)
)
;
for
j
:
=
0
to
Pred
(
Min
(
BufSize
,
SizeUInt
(
Length
(
S
)
-
i
*
BufSize
)
)
div
BitSizeOf
(
SizeUInt
)
)
do
begin
Mask
:
=
PSizeUInt
(
@
MaskBuf
[
j
*
SizeOf
(
SizeUInt
)
]
)
^
;
end
;
end
;
In this code I process a string by chunks and in some moment k becomes High(SizeUInt). The types of variables in this sample is SizeUInt. What I missing?
Logged
Lazarus v. 4.99. FPC v. 3.3.1. Windows 11
jamie
Hero Member
Posts: 7832
Re: Overflow problem
«
Reply #1 on:
July 05, 2026, 06:06:36 pm »
looks like you are using zero index.
The length of the loop should be one less /
for I := 0 To Lenght(S)-1
Logged
The only true wisdom is knowing you know nothing
LemonParty
Hero Member
Posts: 557
Re: Overflow problem
«
Reply #2 on:
July 05, 2026, 07:23:09 pm »
Changed
Code: Pascal
[Select]
[+]
[-]
for
i
:
=
0
to
Length
(
S
)
div
BufSize
do
begin
to
Code: Pascal
[Select]
[+]
[-]
for
i
:
=
0
to
Pred
(
Length
(
S
)
)
div
BufSize
do
begin
Seems working.
Thank you.
Logged
Lazarus v. 4.99. FPC v. 3.3.1. Windows 11
Print
Pages: [
1
]
« previous
next »
Lazarus
»
Forum
»
Programming
»
General
»
Overflow problem
TinyPortal
© 2005-2018