Bugs

General discussion for topics related to the FreeBASIC project or its community.
Post Reply
dodicat
Posts: 7976
Joined: Jan 10, 2006 20:30
Location: Scotland

Re: Bugs

Post by dodicat »

Found a bug in the documentation code.
https://www.freebasic.net/wiki/KeyPgDdfberr

if -exx is used
...FBIde0.4.6r4\FBIde0.4.6r4\FBIDETEMP.bas(4) warning 25(1): Overflow in constant conversion
...FBIde0.4.6r4\FBIde0.4.6r4\FBIDETEMP.bas(4) warning 25(1): Overflow in constant conversion

using the example given with -exx
Tested 32 gas/gcc
Tested 64 and gas64

Code: Select all

#cmdline "-exx"
Dim err_command_line As UByte
err_command_line = __FB_ERR__
Select Case err_command_line
Case 0
Print "No Error Checking enabled on the Command Line!"
Case 1
Print "Some Error Checking enabled on the Command Line!"
Case 3
Print "QBasic style Error Checking enabled on the Command Line!"
Case 7
Print "Extreme Error Checking enabled on the Command Line!"
Case Else
Print "Some Unknown Error level has been set!"
End Select
sleep

 
Ubyte is too small for __FB_ERR__
__FB_ERR__ is 287
No cases are caught.
fxm
Moderator
Posts: 12082
Joined: Apr 22, 2009 12:46
Location: Paris suburbs, FRANCE

Re: Bugs

Post by fxm »

Referring to the above Dodicat' post, I also find weird values of __FB_ERR__ for:
"-e" (513 instead of 1)
"-exx" (287 instead of 7)

Other question: I suppose that __FB_ERR__ is defined as an INTEGER ?
adeyblue
Posts: 299
Joined: Nov 07, 2019 20:08

Re: Bugs

Post by adeyblue »

__FB_ERR__ is a set of flags rather than one single value - looks like several things have been added since the doc was written
https://github.com/freebasic/fbc/blob/3 ... e.bas#L116
fxm
Moderator
Posts: 12082
Joined: Apr 22, 2009 12:46
Location: Paris suburbs, FRANCE

Re: Bugs

Post by fxm »

The only "-e" option must produce 1.
The only "-exx" option must provide 7 (4 OR 2 OR 1) because "-exx" (4) implies "-ex" (2) that implies "-e" (1).
SARG
Posts: 1756
Joined: May 27, 2005 7:15
Location: FRANCE

Re: Bugs

Post by SARG »

-exx implies more :

- array check = 8
- null ptr check = 16
- full error location = 256

so 7+8+16+256 = 287

In the example ubyte must be changed. And the select/case could be completed.

Edit : __FB_ERR__ contains also information about debugging/assertion. Using -g --> 511

Edit2 : 513 is due to 512 added in case of unwind info. Also added if -e is used. Should it be ?
fxm
Moderator
Posts: 12082
Joined: Apr 22, 2009 12:46
Location: Paris suburbs, FRANCE

Re: Bugs

Post by fxm »

Thanks.
But the weird value corresponding to the "-e" compiler option remains and is illogical compared to "-ex" and "-exx" (because "-ex" implies "-e", and "-exx" implies "-ex" and so "-e").
fxm
Moderator
Posts: 12082
Joined: Apr 22, 2009 12:46
Location: Paris suburbs, FRANCE

Re: Bugs

Post by fxm »

SARG wrote: May 11, 2022 23:59 Edit : __FB_ERR__ contains also information about debugging/assertion. Using -g --> 511
???

In addition, this code induces a "'Compilation failed" with "gas64":
#cmdline "-g"
fxm
Moderator
Posts: 12082
Joined: Apr 22, 2009 12:46
Location: Paris suburbs, FRANCE

Re: Bugs

Post by fxm »

Otherwise, for the documentation, I would prefer a table rather like this:

Code: Select all

Returns bit-wise OR of the following values:
    | value | flag          | description                     |
    | 0     | no flag       |                                 |
    | 1     | errorcheck    | implied by '-e', '-ex', '-exx'  |
    | 2     | resumeerr     | implied by '-ex', '-exx'        |
    | 4     | extraerrchk   | implied by '-exx'               |
    | 8     | arrayboundchk | implied by '-earray', '-exx'    |
    | 16    | nullptrchk    | implied by '-enullptr', '-exx'  |
    | 32    | assertions    | implied by '-eassert', '-g'     |
    | 64    | debuginfo     | implied by '-edebuginfo', '-g'  |
    | 128   | debug         | implied by '-edebug', '-g'      |
    | 256   | errlocation   | implied by '-elocation', '-exx' |
    | 512   | unwindinfo    | implied by '-eunwind'           |
SARG
Posts: 1756
Joined: May 27, 2005 7:15
Location: FRANCE

Re: Bugs

Post by SARG »

fxm wrote: May 12, 2022 5:25 Thanks.
But the weird value corresponding to the "-e" compiler option remains and is illogical compared to "-ex" and "'-exx" (because "-ex" implies "-e", and "-exx" implies "-ex" and so "-e").
I agree, that's the reason I wrote "Should it be ?".

fxm wrote: May 12, 2022 6:28 SARG wrote: ↑Thu May 12, 2022 0:59
Edit : __FB_ERR__ contains also information about debugging/assertion. Using -g --> 511
???
Using -exx and -g. But I suppose that now you already understand.

fxm wrote: May 12, 2022 6:28 In addition, this code induces a "'Compilation failed" with "gas64":
#cmdline "-g"
I tested -g directly in the command line and no problem.
Yes, the compiler crashes if used as a preprocessor directive. I'll fix that.

What you propose for the documentation is better.
fxm
Moderator
Posts: 12082
Joined: Apr 22, 2009 12:46
Location: Paris suburbs, FRANCE

Re: Bugs

Post by fxm »

@Jeff and the others,

- __FB_ERR__ documentation page updated.
- Only remains the weird value ('513' while '1' is expected) for the '-e' option, illogical compared to '-ex' and '-exx' (because '-ex' implies '-e', and '-exx' implies '-ex' and so '-e')
SARG
Posts: 1756
Joined: May 27, 2005 7:15
Location: FRANCE

Re: Bugs

Post by SARG »

fxm wrote: May 12, 2022 8:41 - Only remains the weird value ('513' while '1' is expected) for the '-e' option, illogical compared to '-ex' and '-exx' (because '-ex' implies '-e', and '-exx' implies '-ex' and so '-e')
I don't know if it was really intended.
Easy to fix/change by just removing one line.

Code: Select all

	case OPT_E
		fbSetOption( FB_COMPOPT_ERRORCHECK, TRUE )
		fbSetOption( FB_COMPOPT_UNWINDINFO, TRUE )  <-------- 

Concerning gas64, the parser is restarted when #cmdline -g is processed. For now I'm still searching how fix it.
dodicat
Posts: 7976
Joined: Jan 10, 2006 20:30
Location: Scotland

Re: Bugs

Post by dodicat »

That's much better fxm.
I don't have #512 -unwindinfo, next one up from the official build I believe.
For fun

Code: Select all

#cmdline "-exx"
Sub evalue( fb_err_value as integer =__fb_err__)
      Dim As String s(...)={"no flag enabled","errorckeck","resumeerror","extraerrchk","arrayboundchk","nullptrchk", _
                            "assertions","debuginfo","debug","errlocation","unwindinfo"}
      If fb_err_value=0 Then Print s(0):Return
            for m as long=0 to 9
            if (fb_err_value And 2^m)=2^m then Print "'";s(m+1);"'"+" flag enabled"
      next
      End Sub
      
evalue()
sleep
 
fxm
Moderator
Posts: 12082
Joined: Apr 22, 2009 12:46
Location: Paris suburbs, FRANCE

Re: Bugs

Post by fxm »

In the documentation example, I preferred to expand the list of all the tests in the code so as not to add difficulty to understanding the use of '__FB_ERR__'.
dodicat
Posts: 7976
Joined: Jan 10, 2006 20:30
Location: Scotland

Re: Bugs

Post by dodicat »

That's fine fxm, of course it is better understood expanded out.
SARG
Posts: 1756
Joined: May 27, 2005 7:15
Location: FRANCE

Re: Bugs

Post by SARG »

Crash fixed.
When #cmdline -g is processed the parsing continues to the end of the current file with this parameter but as initializations of dynamic arrays were not done -> crash.

As the parsing is completly redone a second time I have asked Jeff (on Discord) why the first parsing is not immediately stopped.
Post Reply