[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Clearing a static array - seg fault
[Thread Prev] | [Thread Next]
- Subject: Clearing a static array - seg fault
- From: Brian G <brian@xxxxxxxxxxxxxxxx>
- Date: Sun, 26 Jan 2025 11:12:00 -0800
- To: GambasList <user@xxxxxxxxxxxxxxxxxxxxxx>
Should clearing a static array in a structure behave the same as a dynamic multi dimensional array and set all values to zero.
Right now it just segfaults. As the structure is not in normal variable space, but fill(0) works fine.
Perhaps clear should call fill(0) in case of static arrays.
Example:
#!/usr/bin/env gbs3
' Gambas Script File Created 01/26/2025 11:00:30
Public Struct mystruct
myArray[100] As Byte
End Struct
Public Sub Main()
Dim myArray As New Byte[100]
Print "Hello world", myArray.count
myArray.Clear()
Print "Hello world", myArray.count
Dim a As New Mystruct
a.myArray = Byte[].FromString("this message")
Print a.myarray.tostring()
a.myArray.Clear()
Quit 0
Catch
Error "Script Error >";; error.text & "\n" & error.where
End
-----------------------------------------------------------------------------
output from runtime :
Hello world 100
Hello world 0
this message
free(): invalid pointer
gbs3 Error : Script had Segmentation fault, Code=6
---------------------------------------------------------------------------
--
~~~~ Brian
Attachment:
OpenPGP_0x78BFB26402F48419.asc
Description: OpenPGP public key
Attachment:
OpenPGP_signature.asc
Description: OpenPGP digital signature
| Re: Clearing a static array - seg fault | Benoît Minisini <benoit.minisini@xxxxxxxxxxxxxxxx> |