Results 1 to 1 of 1

Thread: union-extends-bug?

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    thinBasic MVPs
    Join Date
    Oct 2012
    Location
    Germany
    Age
    55
    Posts
    1,554
    Rep Power
    174

    union-extends-bug?

    What's going on here?

    This is a small testscript. As far as i know it should print out 4 times 8...

    Uses "console"
    
    Alias Quad As t_DataHandle
    
    Type t_DecodeDataHandle
      pData As DWord
      pType As DWord
    End Type
      
    Union u_DataHandle
      hndl As t_DataHandle
      my   As t_DecodeDataHandle 
    End Union
    
    
    Type any_Data Extends u_DataHandle
      Be As Function
      Is As Function
    End Type  
    Function any_Data.Be(ByVal s As String)
      If HEAP_Size(Me.my.pData) Then HEAP_Free(Me.my.pData)
      Me.my.pData = HEAP_AllocByStr(s) 
    End Function
    Function any_Data.Is() As String  
      Function = HEAP_Get(Me.my.pData)
    End Function
    
    
    PrintL "quad:              " & SizeOf(Quad)      
    PrintL "t_DecodeDataHandle " & SizeOf(t_DecodeDataHandle)
    PrintL "u_DataHandle       " & SizeOf(u_DataHandle)
    PrintL "any_Data           " & SizeOf(any_Data)
    
    'PrintL
    'Dim foo As any_Data
    'foo.Be("some data")
    'PrintL foo.is
      
    PrintL " -- key to end --"
    WaitKey
    
    now what surprise... the extended type is double the size but has no additional subelements...

    but now becomes weird:
    goto line 12 that says:
      my   As t_DecodeDataHandle
    
    and remove "my As" so it just says:
      t_DecodeDataHandle
    
    now the union becomes larger but the extended type equals the unions size... strange...
    Last edited by ReneMiner; 04-10-2014 at 14:09.
    I think there are missing some Forum-sections as beta-testing and support

Similar Threads

  1. is Union a step to dynamic UDT-arrays?
    By ReneMiner in forum Core module
    Replies: 5
    Last Post: 18-05-2013, 15:15
  2. Quote Of the Day Guess the output (Union)
    By ErosOlmi in forum QOD: Question Of the Day
    Replies: 3
    Last Post: 09-02-2013, 10:08
  3. Using MAT on an array within a Union
    By dcromley in forum Core module
    Replies: 5
    Last Post: 09-04-2009, 11:51

Members who have read this thread: 0

There are no members to list at the moment.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •