[Gambas-bugtracker] Bug #1757: Reading a struct as an object causes serialization error, Writing seems to work

bugtracker at gambaswiki.org bugtracker at gambaswiki.org
Sun Mar 15 22:52:33 CET 2020


http://gambaswiki.org/bugtracker/edit?object=BUG.1757&from=L21haW4-

Brian G reported a new bug.

Summary
-------

Reading a struct as an object causes serialization error, Writing seems to work

Type             : Bug
Priority         : Medium
Gambas version   : Master
Product          : Development Environment


Description
-----------

The following code cause a serialization error upon reading the structure from the file.
Memory dump shows the data appears to be written correctly.

' Gambas module file

Public Struct myStruct 

  a As Integer
  b As Float
  c As String 
  
End Struct


Public Sub Main()

Dim Memfile As Pointer
Dim TheStruct As New MyStruct

TheStruct.c = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
TheStruct.b = 4
TheStruct.a = 4.4

memfile = Alloc(2000)

Dim mFile As File
mfile = Memory MemFile For Write
Write #mFile, TheStruct As Object
Close mfile

mfile = Memory MemFile For Read
TheStruct = Read #mFile As Object

Print TheStruct.a
Print TheStruct.b
Print TheStruct.c

Free(memfile)
Close mfile

End


System information
------------------

master




More information about the Bugtracker mailing list