Share

FreeBASIC Compiler

Tracker: Bugs

5 UDT Default Value Array - ID: 2855461
Last Update: Comment added ( counting_pine )

It gives a segfault if the default value is an empty string, and I try to
do anything with that string (Printing or assigning).

Try this code:

---- test.bas ----
Type TypeA
v As String
Declare Constructor(v As String = "")
End Type
Constructor TypeA(v As String)
'' Comment this out and no segfault occurs.
Print v
End Constructor

Print "Declare"
Redim Shared iplist() As TypeA
Print "Size"
Redim iplist(1 to 2) As TypeA
Print "End"
---- End File ----


Brad Landis ( bradlis7 ) - 2009-09-09 20:00

5

Open

None

André Victor T. Vicentini

compiler

None

Public


Comments ( 2 )

Date: 2009-09-10 06:39
Sender: counting_pine

Hmm, it seems to be passing a reference to an integer with a value of 1
(which is the strptr part of the string descriptor):

Type TypeA
v As String
Declare Constructor(v As String = "")
End Type

Constructor TypeA(v As String)
Print strptr(v)
End Constructor

Print "Declare"
Redim Shared iplist() As TypeA
Print "Size"
Redim iplist(1 to 2) As TypeA
Print "End"



Date: 2009-09-09 20:39
Sender: bradlis7Accepting Donations

One way to get around the issue, is to use to use two separate constructors
(Add "Constructor TypeA() ")


Attached File

No Files Currently Attached

Change

No changes have been made to this artifact.