GLBasic forum

Main forum => Bug Reports => Topic started by: bigsofty on 2008-Aug-13

Title: Trying to compile v5.119 source now causes crash?
Post by: bigsofty on 2008-Aug-13
Trying to get back up to speed. OK I've reduced this to its base error... I think?

Well, a program that used to compile and run fine, now crashes...

I have a function that loads some data when a filename is passed to it.

If I use the following in the main program...

Code (glbasic) Select
GLOBAL lastfont = addfont("fnt_test")

The program crashes when run, without a compile error.

So I reduced the "addfont()" code to one line that seemed to be causing the crash...

Code (glbasic) Select
FUNCTION addfont: filename$ // Create a new font
INIOPEN filename$+".ini" <-------------------------- If I remove this line it does not crash?
ENDFUNCTION


As I said, this used to work, the .exe is still in the folder from the last v5.119 compiler and it runs. The latest compiler seems to be not allowing this?
Title: Re: Trying to compile v5.119 source now causes crash?
Post by: Moru on 2008-Aug-13
This is due to the line

Code (glbasic) Select
GLOBAL lastfont = addfont("fnt_test")

Never declare a variable and call a function to initialize it on the same line, break it into two lines:

Code (glbasic) Select
GLOBAL lastfont
lastfont = addfont("fnt_test")
Title: Re: Trying to compile v5.119 source now causes crash?
Post by: Kitty Hello on 2008-Aug-13
Right. GLOBAL a=function() is bad!
The code is getting called _before_ any GLBasic initialization is done, thus it breaks with some internal functions. INIOPEN is one.
Title: Re: Trying to compile v5.119 source now causes crash?
Post by: bigsofty on 2008-Aug-13
OK, thanks for the quick heads up guys.   

Some times I get a little carried away with all the various methods of manipulating types/vars GLB has... :whistle:

Possibly worth adding this to the syntax check parsing though, as it compiles fine?

Thanks again!  :good:
Title: Re: Trying to compile v5.119 source now causes crash?
Post by: Schranz0r on 2008-Aug-13
your function return nothing  :nana:
Title: Re: Trying to compile v5.119 source now causes crash?
Post by: Moru on 2008-Aug-13
He removed everything until he found out where it crashed, that was the only line he could leave in there to still have the crash :)