FreeBASIC 1.09.0 Release

General discussion for topics related to the FreeBASIC project or its community.
Post Reply
srvaldez
Posts: 3606
Joined: Sep 25, 2005 21:54

Re: FreeBASIC 1.08.1 and 1.09.0 Development

Post by srvaldez »

found an anomaly with FB-win64 from 2021-8-8 64-bit version, both gen gcc and gen gas64
code reduced to minimum only to show the error

Code: Select all

Dim y As Double

function gs(byval  z as double) as double
	dim as double a, y

	y=y*(z+a)^(z+.5)*exp(-z-a)
	
	return y
end function

y = gs(.5)
Print y '<-- causes the error
sleep
fbc64 -t 2048 -w all -arch native -gen gcc -Wc -O2 -v "foo.bas"
FreeBASIC Compiler - Version 1.09.0 (2021-08-08), built for win64 (64bit)
Copyright (C) 2004-2021 The FreeBASIC development team.
standalone
target: win64, x86-64, 64bit
backend: gcc
compiling: foo.bas -o foo.c (main module)
compiling C: FreeBASIC-1.09.0-win-gcc-9.3\bin\win64\gcc.exe -m64 -march=native -S -nostdlib -nostdinc -Wall -Wno-unused -Wno-main -Werror-implicit-function-declaration -O0 -fno-strict-aliasing -frounding-math -fno-math-errno -fwrapv -fno-exceptions -fno-unwind-tables -fno-asynchronous-unwind-tables -Wno-format -masm=intel "foo.c" -o "foo.asm" -O2
assembling: FreeBASIC-1.09.0-win-gcc-9.3\bin\win64\as.exe --64 --strip-local-absolute "foo.asm" -o "foo.o"
foo.asm: Assembler messages:
foo.asm:62: Error: unsupported syntax for `call'
assembling failed: 'FreeBASIC-1.09.0-win-gcc-9.3\bin\win64\as.exe' terminated with exit code 1
Compilation failed.
if I add -asm att to the compile command then there's no problem
compiles ok in 32-bit
fxm
Moderator
Posts: 12548
Joined: Apr 22, 2009 12:46
Location: Paris suburbs, FRANCE

Re: FreeBASIC 1.08.1 and 1.09.0 Development

Post by fxm »

It is the procedure name 'gs' which causes the problem in 64-bit.

Code: Select all

sub gs()
end sub

gs()
Ditto for 'fs', 'cs', .....
(all register names)
srvaldez
Posts: 3606
Joined: Sep 25, 2005 21:54

Re: FreeBASIC 1.08.1 and 1.09.0 Development

Post by srvaldez »

hello fxm
there's more to the story
the following compiles ok, still same function name

Code: Select all

Dim y As Double

function gs(byval  z as double) as double
	dim as double a, y

	y=exp(-z-a)
	
	return y
end function

y = gs(.5)
Print y
sleep
SARG
Posts: 1876
Joined: May 27, 2005 7:15
Location: FRANCE

Re: FreeBASIC 1.08.1 and 1.09.0 Development

Post by SARG »

With gas64 in every case there is a 'call GS' which is not allowed.

edit segment registers : CS, SS, DS, ES, FS and GS
fxm
Moderator
Posts: 12548
Joined: Apr 22, 2009 12:46
Location: Paris suburbs, FRANCE

Re: FreeBASIC 1.08.1 and 1.09.0 Development

Post by fxm »

srvaldez wrote:hello fxm
there's more to the story
the following compiles ok, still same function name

Code: Select all

Dim y As Double

function gs(byval  z as double) as double
	dim as double a, y

	y=exp(-z-a)
	
	return y
end function

y = gs(.5)
Print y
sleep
For me, this code also doesn't compile (for 64-bit).
fxm
Moderator
Posts: 12548
Joined: Apr 22, 2009 12:46
Location: Paris suburbs, FRANCE

Re: FreeBASIC 1.08.1 and 1.09.0 Development

Post by fxm »

@Jeff, @admins (and other developers)

I would like to add in the documentation a special warning about choosing user procedure identifier names in the global namespace (in addition to the classic alphanumeric rules and the uniqueness of identifier names in the source code).
But this additional restriction only seems to affect the 64-bit compiler with the names of the segment registers (CS, SS, DS, ES, FS and GS).
Is it correct ?
SARG
Posts: 1876
Joined: May 27, 2005 7:15
Location: FRANCE

Re: FreeBASIC 1.08.1 and 1.09.0 Development

Post by SARG »

@fxm what I can say
With gcc64 and gas64 unlike with gcc32/gas32 procedure names are not decorated so using ALL register names are forbidden : assembly errors (segment registers), unexpected results or more probably crashes (other registers).
fxm
Moderator
Posts: 12548
Joined: Apr 22, 2009 12:46
Location: Paris suburbs, FRANCE

Re: FreeBASIC 1.08.1 and 1.09.0 Development

Post by fxm »

@SARG, thank you.
It also seems useful to caution against using names from other registries, which can cause runtime bugs only.
dodicat
Posts: 8239
Joined: Jan 10, 2006 20:30
Location: Scotland

Re: FreeBASIC 1.08.1 and 1.09.0 Development

Post by dodicat »

You could namespace the forbidden, alias the forbidden or best, don't use the forbidden.
But the 64 bit compiler gives an error at the forbidden (all cases??), so it is not as if you could use the forbidden or get caught out with it as a bug, unless of course you create your program in 32 bits in the first place.
Linux as I remember, is fussy in 32 bits also, but my Linux box is in storage in the attic,(overheating processors, needing taken apart and re greased).

Code: Select all


Dim y As Double


Function fs Alias "b"(Byval  z As Double) As Double
      Dim As Double a, y
      
      y=Exp(-z-a)
      
      Return y
End Function

Sub b
      Print fs(2)
End Sub

y = fs(.5)
Print y
b

Sleep 
SARG
Posts: 1876
Joined: May 27, 2005 7:15
Location: FRANCE

Re: FreeBASIC 1.08.1 and 1.09.0 Development

Post by SARG »

call GS --> assembly error so compilation failed

call RDX --> no compilation error but unexpected result or probably a crash
dodicat
Posts: 8239
Joined: Jan 10, 2006 20:30
Location: Scotland

Re: FreeBASIC 1.08.1 and 1.09.0 Development

Post by dodicat »

Thanks SARG.
paul doe
Posts: 1859
Joined: Jul 25, 2017 17:22
Location: Argentina
Contact:

Re: FreeBASIC 1.08.1 and 1.09.0 Development

Post by paul doe »

fxm wrote:@SARG, thank you.
It also seems useful to caution against using names from other registries, which can cause runtime bugs only.
There are also other nasty situations that arise if one uses assembler symbols as procedure names, say:

Code: Select all

sub word()
  ? "Hai!"
end sub

dim as sub() f = @word

f()
So I'd say the warning in the manual is not a bad idea, indeed...
srvaldez
Posts: 3606
Joined: Sep 25, 2005 21:54

Re: FreeBASIC 1.08.1 and 1.09.0 Development

Post by srvaldez »

if you are not using intel inline asm in your code then you can solve all this by including -asm att in the compile command
paul doe wrote: There are also other nasty situations that arise if one uses assembler symbols as procedure names, say:

Code: Select all

sub word()
  ? "Hai!"
end sub

dim as sub() f = @word

f()
using -asm att the output is Hai!
dodicat
Posts: 8239
Joined: Jan 10, 2006 20:30
Location: Scotland

Re: FreeBASIC 1.08.1 and 1.09.0 Development

Post by dodicat »

Code: Select all

sub Ԝord()
 ? "Hai!"
end sub

dim as sub() f = @Ԝord


f() 
sleep
Yes, strange result, even with 32 bits
Last edited by dodicat on Aug 26, 2021 15:46, edited 1 time in total.
fxm
Moderator
Posts: 12548
Joined: Apr 22, 2009 12:46
Location: Paris suburbs, FRANCE

Re: FreeBASIC 1.08.1 and 1.09.0 Development

Post by fxm »

This is part of what I called above the "classic alphanumeric rules" among which the identifier must start with an alphabetic character or with an "_" (see Identifier Rules).
Post Reply