Compiler bug (see forum at https://www.freebasic.net/forum/viewtopic.php?f=3&t=25865):
From inside a non static member procedure, ThreadCall allows to start as a thread a non static member Sub (without any parameters), which crashes only if attempting to access a non static member field (same execution behavior than calling a non static member procedure on a null pointer).
In the following example, the two syntaxes should be disallowed by the compiler and induce a compiler error message:
Type UDT Dim As Integer value Declare Sub thread () Declare Sub thread_start () end type Sub UDT.thread () Do Print "IT WORKS!" ', value '' program crashes when accessing to value Loop Until Inkey <> "" End Sub Sub UDT.thread_start () 'Threadcall This.thread() '' compiler error => OK Threadcall UDT.thread() '' no compiler error => NOK Threadcall thread() '' no compiler error => NOK End Sub Dim As UDT u u.thread_start Sleep
As soon as the Sub() thread has a parameter to pass, the compiler outputs an error message, but that: "error 24: Invalid data types".
Last edit: fxm (freebasic.net) 2017-08-18