Compiler Segfaults when trying to compile

General FreeBASIC programming questions.
Post Reply
Imortis
Moderator
Posts: 1925
Joined: Jun 02, 2005 15:10
Location: USA
Contact:

Compiler Segfaults when trying to compile

Post by Imortis »

Here is a link to the code. The file you want is the Test.bas

I am using the latest Release (0.20.0b) on Windows XP SP3.

EDIT:
Link Removed. Se voodooattack's post for condensed code.
Last edited by Imortis on Aug 20, 2008 23:10, edited 1 time in total.
counting_pine
Site Admin
Posts: 6323
Joined: Jul 05, 2005 17:32
Location: Manchester, Lancs

Post by counting_pine »

I can't reproduce the segfault. I just get:

Code: Select all

Test.bas(21) error 68: Array access, index expected, before ')' in 'HandleObjectArray(tester)'
Can you be more specific? What command line did you use? What error do you get?
Imortis
Moderator
Posts: 1925
Joined: Jun 02, 2005 15:10
Location: USA
Contact:

Post by Imortis »

I'm sorry. I sent the wrong version of the file.

Line 21 should look like this:

Code: Select all

handleObjectArray(tester())
Also, I'm using -s gui on the command line. That's it.
voodooattack
Posts: 605
Joined: Feb 18, 2006 13:30
Location: Alexandria / Egypt
Contact:

Post by voodooattack »

This is caused by your UDT having a destructor and no default constructor.
A temporary solution is to add an empty constructor to your type.

this is caused by rtlArrayClear, in rtl-array.bas

Code: Select all

    if( dtor = NULL ) then
        ...
    else
        ...
		
		if( symbGetProcMode( ctor ) <> FB_FUNCMODE_CDECL ) then
			errReport( FB_ERRMSG_REDIMCTORMUSTBECDEL )
		end if

		if( symbGetProcMode( dtor ) <> FB_FUNCMODE_CDECL ) then
			errReport( FB_ERRMSG_REDIMCTORMUSTBECDEL )
		end if

        ...
        
    end if
the first IF statement tries to access a null pointer.. I thought about fixing it by adding a local null pointer check at this point, but i'm not really sure if that is the way to handle it correctly.

but I managed to isolate the problem into a test case:

Code: Select all

type foo
    as integer dummy
    ' declare constructor
    declare destructor
end type


' constructor foo()
'    ''
' end constructor
    
destructor foo()
    ''
end destructor

dim x(1) as foo
the problem doesn't occur with dynamic arrays though.
Imortis
Moderator
Posts: 1925
Joined: Jun 02, 2005 15:10
Location: USA
Contact:

Post by Imortis »

Thank you very much voodooattack. I tried everything I could think of to get it isolated like that. I never even thought about the destructor. I was going to add a consturctor to it anyway, so that works out well.
Post Reply