Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

high, len function with sequences #4

Closed
adilkhash opened this issue Jan 2, 2011 · 1 comment
Closed

high, len function with sequences #4

adilkhash opened this issue Jan 2, 2011 · 1 comment

Comments

@adilkhash
Copy link

Hi.

Following code:

var q: seq[int]
q = @[1,2,3,4,5]
q[high(q)+1] = 10
q[high(q)+2] = 666

echo($high(q))
echo($len(q))
echo($q[5])

C:\nimrod>nimrod c -d:release --opt:size hello
4
5
10

It means that high and len functions are based on static information about sequences?
Maybe echo($high(q)) should print 6 and echo($len(q)) should 7 ?

And if I compile without -d:release and --opt:size (just pure nimrod c hello.nim), I get the following error:

Traceback (most recent call last)
hello.nim(10) hello
Error: unhandled exception: index out of bounds [EInvalidIndex]

Where I'm wrong?

@Araq
Copy link
Member

Araq commented Jan 3, 2011

Error: unhandled exception: index out of bounds [EInvalidIndex]
is correct. However, index checks are not generated in release mode so you corrupt memory instead. Use 'add' to append to a sequence.

dom96 pushed a commit that referenced this issue May 31, 2018
Araq pushed a commit that referenced this issue Jun 7, 2018
DongyunLee pushed a commit to nim-lang-cn/Nim that referenced this issue Nov 18, 2019
n5m added a commit to n5m/Nim that referenced this issue Jul 11, 2021
# This is the 1st commit message:

default last in strutils.find to -1

# This is the commit message nim-lang#2:

Revert "default last in strutils.find to -1"

This reverts commit 3a99556.

# This is the commit message nim-lang#3:

add openArray variable of find with SkipTable

# This is the commit message nim-lang#4:

add find method that accepts an openArray

# This is the commit message nim-lang#5:

add tests

# This is the commit message nim-lang#6:

Revert "add find method that accepts an openArray"

This reverts commit 2ab5351.

# This is the commit message nim-lang#7:

Revert "add openArray variable of find with SkipTable"

This reverts commit 58159fc.
n5m added a commit to n5m/Nim that referenced this issue Jul 11, 2021
# This is the 1st commit message:

default last in strutils.find to -1

# This is the commit message nim-lang#2:

Revert "default last in strutils.find to -1"

This reverts commit 3a99556.

# This is the commit message nim-lang#3:

add openArray variable of find with SkipTable

# This is the commit message nim-lang#4:

add find method that accepts an openArray

# This is the commit message nim-lang#5:

add tests

# This is the commit message nim-lang#6:

Revert "add find method that accepts an openArray"

This reverts commit 2ab5351.

# This is the commit message nim-lang#7:

Revert "add openArray variable of find with SkipTable"

This reverts commit 58159fc.
n5m added a commit to n5m/Nim that referenced this issue Aug 21, 2021
# This is the 1st commit message:

default last in strutils.find to -1

# This is the commit message nim-lang#2:

Revert "default last in strutils.find to -1"

This reverts commit 3a99556.

# This is the commit message nim-lang#3:

add openArray variable of find with SkipTable

# This is the commit message nim-lang#4:

add find method that accepts an openArray

# This is the commit message nim-lang#5:

add tests

# This is the commit message nim-lang#6:

Revert "add find method that accepts an openArray"

This reverts commit 2ab5351.

# This is the commit message nim-lang#7:

Revert "add openArray variable of find with SkipTable"

This reverts commit 58159fc.
n5m added a commit to n5m/Nim that referenced this issue Jan 5, 2022
# This is the 1st commit message:

default last in strutils.find to -1

# This is the commit message nim-lang#2:

Revert "default last in strutils.find to -1"

This reverts commit 3a99556.

# This is the commit message nim-lang#3:

add openArray variable of find with SkipTable

# This is the commit message nim-lang#4:

add find method that accepts an openArray

# This is the commit message nim-lang#5:

add tests

# This is the commit message nim-lang#6:

Revert "add find method that accepts an openArray"

This reverts commit 2ab5351.

# This is the commit message nim-lang#7:

Revert "add openArray variable of find with SkipTable"

This reverts commit 58159fc.
krux02 pushed a commit to krux02/Nim that referenced this issue Jan 11, 2022
* Fixed borrowing procs with typeclasses
* added comments to tests/borrow/typeclassborrow
ci4ic4 added a commit to ci4ic4/Nim that referenced this issue Dec 30, 2022
tlsEmulation:on under NetBSD-10Beta and NetBSD-current produces an executable which crashes immediately as follows:

Core was generated by `koch'.
Program terminated with signal SIGSEGV, Segmentation fault.
#0  0x000000000047b4c2 in nimZeroMem ()
(gdb) bt
#0  0x000000000047b4c2 in nimZeroMem ()
nim-lang#1  0x00000000004897b2 in threadVarAlloc__system_2162 ()
nim-lang#2  0x000000000048980e in initThreadVarsEmulation ()
nim-lang#3  0x0000000000489848 in PreMain ()
nim-lang#4  0x000000000048986a in NimMain ()
nim-lang#5  0x00000000004898a9 in main ()

I can't speak about the other BSDs.
Araq pushed a commit that referenced this issue Jan 2, 2023
tlsEmulation:on under NetBSD-10Beta and NetBSD-current produces an executable which crashes immediately as follows:

Core was generated by `koch'.
Program terminated with signal SIGSEGV, Segmentation fault.
#0  0x000000000047b4c2 in nimZeroMem ()
(gdb) bt
#0  0x000000000047b4c2 in nimZeroMem ()
#1  0x00000000004897b2 in threadVarAlloc__system_2162 ()
#2  0x000000000048980e in initThreadVarsEmulation ()
#3  0x0000000000489848 in PreMain ()
#4  0x000000000048986a in NimMain ()
#5  0x00000000004898a9 in main ()

I can't speak about the other BSDs.
narimiran pushed a commit that referenced this issue Jan 2, 2023
tlsEmulation:on under NetBSD-10Beta and NetBSD-current produces an executable which crashes immediately as follows:

Core was generated by `koch'.
Program terminated with signal SIGSEGV, Segmentation fault.
#0  0x000000000047b4c2 in nimZeroMem ()
(gdb) bt
#0  0x000000000047b4c2 in nimZeroMem ()
#1  0x00000000004897b2 in threadVarAlloc__system_2162 ()
#2  0x000000000048980e in initThreadVarsEmulation ()
#3  0x0000000000489848 in PreMain ()
#4  0x000000000048986a in NimMain ()
#5  0x00000000004898a9 in main ()

I can't speak about the other BSDs.

(cherry picked from commit e9ed090)
capocasa pushed a commit to capocasa/Nim that referenced this issue Mar 31, 2023
tlsEmulation:on under NetBSD-10Beta and NetBSD-current produces an executable which crashes immediately as follows:

Core was generated by `koch'.
Program terminated with signal SIGSEGV, Segmentation fault.
#0  0x000000000047b4c2 in nimZeroMem ()
(gdb) bt
#0  0x000000000047b4c2 in nimZeroMem ()
nim-lang#1  0x00000000004897b2 in threadVarAlloc__system_2162 ()
nim-lang#2  0x000000000048980e in initThreadVarsEmulation ()
nim-lang#3  0x0000000000489848 in PreMain ()
nim-lang#4  0x000000000048986a in NimMain ()
nim-lang#5  0x00000000004898a9 in main ()

I can't speak about the other BSDs.
bung87 pushed a commit to bung87/Nim that referenced this issue Jul 29, 2023
tlsEmulation:on under NetBSD-10Beta and NetBSD-current produces an executable which crashes immediately as follows:

Core was generated by `koch'.
Program terminated with signal SIGSEGV, Segmentation fault.
#0  0x000000000047b4c2 in nimZeroMem ()
(gdb) bt
#0  0x000000000047b4c2 in nimZeroMem ()
#1  0x00000000004897b2 in threadVarAlloc__system_2162 ()
#2  0x000000000048980e in initThreadVarsEmulation ()
nim-lang#3  0x0000000000489848 in PreMain ()
nim-lang#4  0x000000000048986a in NimMain ()
nim-lang#5  0x00000000004898a9 in main ()

I can't speak about the other BSDs.
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants