segmentation fault using default initializer

General FreeBASIC programming questions.
Post Reply
srvaldez
Posts: 3373
Joined: Sep 25, 2005 21:54

segmentation fault using default initializer

Post by srvaldez »

the following code segfaults on macOS (same problem on Windows -- using appropriate registers of course)

Code: Select all

function scanf_long_double(byref x as string , byref frmt as string= "%Lf") as clongdouble
	dim as clongdouble y
	asm
		"movq %[X$1],%%rdi \n" _
		"movq (%%rdi),%%rdi \n" _
		"movq %[FRMT$1],%%rsi \n" _
		"movq (%%rsi),%%rsi \n" _
		"leaq %[Y$1],%%rdx \n" _
		"call _sscanf  \n" _
		: _
		:[frmt]"m"(frmt),[x]"m"(x),[y]"m"(y)  _
		:"rdi","rsi","rdx"
	end asm
	function = y
end function
if I change the code to this it works OK

Code: Select all

function scanf_long_double(byref x as string , byref frmt as string= "") as clongdouble
	dim as clongdouble y
	frmt = "%Lf"
....
it's no big deal to me but perhaps it could help others.
you need to compile with -asm att
Post Reply