Free Basic Compilers Version 1.06.0 (08-26-2018) seem broken

General FreeBASIC programming questions.
jj2007
Posts: 1233
Joined: Oct 23, 2016 15:28
Location: Roma, Italia
Contact:

Re: Free Basic Compilers Version 1.06.0 (08-26-2018) seem broken

Postby jj2007 » Sep 03, 2018 15:14

Josep Roca wrote:You can use SetWIndowText or the macro Edit_SetText.
Yes, in this particular case. But that is not a generally applicable solution. SendMessage (and there are probably other functions) accepts parameters of variable types, depending on the message. Therefore the compiler needs to check the WM_* message (about 300) to determine the correct type. The type specified for the function's lParam is not the correct type.

[Do you notice that I write as if I was obsessed with type checking?]
deltarho[1859]
Posts: 2003
Joined: Jan 02, 2017 0:34
Location: UK

Re: Free Basic Compilers Version 1.06.0 (08-26-2018) seem broken

Postby deltarho[1859] » Sep 03, 2018 15:26

jj2007 wrote:[Do you notice that I write as if I was obsessed with type checking?]

It is the only way one should write on a programming forum. More is the pity that many do not and often result in more posts that are actually required. <smile>
jj2007
Posts: 1233
Joined: Oct 23, 2016 15:28
Location: Roma, Italia
Contact:

Re: Free Basic Compilers Version 1.06.0 (08-26-2018) seem broken

Postby jj2007 » Sep 03, 2018 16:26

deltarho[1859] wrote:It is the only way one should write on a programming forum.
I am not against typechecking; on other occasions, I argue a lot with people who think they can do better without. But I am in favour of checking correctly what a function really needs, and I am strictly against casting acrobatics, not only because it's an ugly mess but also because it most often means that the typechecking procedure and/or the headers are seriously flawed. If 10% of your lines in a simple (and correctly working) Windows GUI program get criticised with warnings, then there is definitely a problem to solve.
MrSwiss
Posts: 3262
Joined: Jun 02, 2013 9:27
Location: Switzerland

Re: Free Basic Compilers Version 1.06.0 (08-26-2018) seem broken

Postby MrSwiss » Sep 03, 2018 16:42

@jj2007,

Sorry to state, but seriously: your arguments about noobs/beginners are simplistic, because:
  • WinAPI is not intended for those groups (to complex, for starters)
  • as by comparison: GTK+ in Linux
All those "jack of all trades" Libraries are essentially, for somewhat advanced programmers use.
(As: "intended audience" may state.)
deltarho[1859]
Posts: 2003
Joined: Jan 02, 2017 0:34
Location: UK

Re: Free Basic Compilers Version 1.06.0 (08-26-2018) seem broken

Postby deltarho[1859] » Sep 04, 2018 10:33

Got the fbc 1.06 (04-Sep-2018) and manual (02-Sep-2018)

Thanks to coderJeff, St_W and fxm.
fxm
Posts: 9178
Joined: Apr 22, 2009 12:46
Location: Paris suburbs, FRANCE

Re: Free Basic Compilers Version 1.06.0 (08-26-2018) seem broken

Postby fxm » Nov 06, 2018 16:21

BUG OR NOT BUG ?
(I vote for bug)

Excerpt from an example of paul doe (https://www.fbcadcam.net/forum/viewtopic.php?p=358#p358), this code no longer compiles with freeBASIC 1.06:

Code: Select all

Type Point
  x As Single
  y As Single
End Type

Type Shape
  points(Any) As Point
end type

Dim As Shape s0

Dim As Const Shape s = s0
Print Ubound(s.points)

Sub test (Byref s As Const Shape)
  Print Ubound(s.points)
  Print s.points(0).x
End Sub
Compiler output:
...\FBIde0.4.6r4_fbc1.06.0\FBIDETEMP.bas(13) error 181: Invalid assignment/conversion, at parameter 1 in 'Print Ubound(s.points)'
...\FBIde0.4.6r4_fbc1.06.0\FBIDETEMP.bas(16) error 181: Invalid assignment/conversion, at parameter 1 in 'Print Ubound(s.points)'
...\FBIde0.4.6r4_fbc1.06.0\FBIDETEMP.bas(17) warning 40(-1): CONST qualifier discarded
(compiled with "-w constness" to obtain the warning)

Note: No problem with a fix-len array in Shape.
Last edited by fxm on Nov 06, 2018 17:06, edited 1 time in total.
fxm
Posts: 9178
Joined: Apr 22, 2009 12:46
Location: Paris suburbs, FRANCE

Re: Free Basic Compilers Version 1.06.0 (08-26-2018) seem broken

Postby fxm » Nov 06, 2018 16:58

Simpler bug:

Code: Select all

Sub simpler_test (array() As Const Integer)
  Print Ubound(array)  '' error 181: Invalid assignment/conversion, at parameter 1 in 'Print Ubound(array)'
End Sub
paul doe
Posts: 922
Joined: Jul 25, 2017 17:22
Location: Argentina

Re: Free Basic Compilers Version 1.06.0 (08-26-2018) seem broken

Postby paul doe » Nov 06, 2018 20:17

fxm wrote:BUG OR NOT BUG ?
(I vote for bug)

Indeed it is. In my version of fbc 1.06 (not the latest) the code compiles without a single problem (no constness warning, no nothing). So, perhaps something was inadvertently broken last build?

Thanks for taking the trouble for testing it, well spotted.
fxm
Posts: 9178
Joined: Apr 22, 2009 12:46
Location: Paris suburbs, FRANCE

Re: Free Basic Compilers Version 1.06.0 (08-26-2018) seem broken

Postby fxm » Nov 06, 2018 20:57

FreeBASIC Compiler used: Version 1.06.0 (10-24-2018).

Obviously if we suppress 'Const' in all declarations, the code compiles.
coderJeff
Site Admin
Posts: 3068
Joined: Nov 04, 2005 14:23
Location: Ontario, Canada
Contact:

Re: Free Basic Compilers Version 1.06.0 (08-26-2018) seem broken

Postby coderJeff » Nov 07, 2018 2:49

Thanks, fix is submitted to https://github.com/freebasic/fbc/pull/112

The changes to fbc in August removed some special cases where const was ignored or improperly handled. Almost all of the internal run time library declarations were modified to include a const qualifier on parameters. I missed updating the declarations for lbound & ubound causing this bug. An easy fix, 2 lines, and I wrote a regression test.

While investigating the L|UBOUND( const array() ) bug reported in this topic, I found this other bug, seen also in fbc 1.05.

Code: Select all

dim shared array(1 to ...) as integer = { 1, 2 }
dim shared const_array(1 to ...) as const integer = { 1, 2 }

sub s( array() as integer )
end sub
sub const_s( array() as const integer )
end sub

s( array() )
const_s( array() )
const_s( const_array() )


fbc 1.05 wrote:xx.c:43:8: error: redefinition of 'struct $8FBARRAY1IiE'
struct $8FBARRAY1IiE {
^~~~~~~~~~~~~
xx.c:32:8: note: originally defined here
struct $8FBARRAY1IiE {
^~~~~~~~~~~~~

So, I have a proposed fix for that as well.

There is still https://sourceforge.net/p/fbc/bugs/823/ to fix, which involves overloaded procedures and const/non-const arrays. It involves a different part of the compiler from these fixes.

Const arrays, especially those passed BYDESC, need a lot more testing.

In general, the parser is supposed to figure out if it is OK to call an internal run time library function. With the changes in 1.06 in August, there may be some cases where the fbc parser misses it, but will catch the error instead when trying to call the run time library function (due the const checking). However, it results in a somewhat cryptic error message, and should be reported as a bug so we can update the parser to report a meaningful error message.
paul doe
Posts: 922
Joined: Jul 25, 2017 17:22
Location: Argentina

Re: Free Basic Compilers Version 1.06.0 (08-26-2018) seem broken

Postby paul doe » Nov 07, 2018 5:47

Wow, that was fast =D

Thank you for your continued work on the compiler, Jeff. Much appreciated =D
fxm
Posts: 9178
Joined: Apr 22, 2009 12:46
Location: Paris suburbs, FRANCE

Re: Free Basic Compilers Version 1.06.0 (08-26-2018) seem broken

Postby fxm » Nov 07, 2018 6:14

@coderJeff,

Thanks.

And what about the warning on the second line in Sub body (referring to viewtopic.php?p=254260#p254260):

Code: Select all

Sub test (Byref s As Const Shape)
  Print Ubound(s.points)
  Print s.points(0).x  '' warning 40(-1): CONST qualifier discarded
End Sub
    (compiling with "-w constness")
Provoni
Posts: 318
Joined: Jan 05, 2014 12:33
Location: Belgium

Re: Free Basic Compilers Version 1.06.0 (08-26-2018) seem broken

Postby Provoni » Nov 07, 2018 8:18

Thanks to everyone for their work on the FreeBASIC project.
coderJeff
Site Admin
Posts: 3068
Joined: Nov 04, 2005 14:23
Location: Ontario, Canada
Contact:

Re: Free Basic Compilers Version 1.06.0 (08-26-2018) seem broken

Postby coderJeff » Nov 07, 2018 10:57

fxm, found the cause of that one also. Can get the warning as well with:

Code: Select all

 
  #print typeof( s.points(0) )
  #print typeof( s.points(0).x )

The top level data type is correct, a const type. It is the internal expression that fbc generates to access the array field that loses the const qualifier. Immediate fix is to have fbc ignore const for the internal expression; I am taking a little time to make sure that makes sense.
coderJeff
Site Admin
Posts: 3068
Joined: Nov 04, 2005 14:23
Location: Ontario, Canada
Contact:

Re: Free Basic Compilers Version 1.06.0 (08-26-2018) seem broken

Postby coderJeff » Nov 12, 2018 1:12

The bugs mentioned in the last few posts should be fixed, and fixes are merged in to master.
- lbound & ubound work with const arrays
- non-const arrays arguments can be passed to const array parameters, (bug fix #823)
- the unnecessary const warning on array indexes in const UDT's is suppressed

If there are additional issues, please consider creating a bug report. It's actually really nice to have a bug report on sf.net to use for tracking.

Return to “General”

Who is online

Users browsing this forum: MSN [Bot] and 16 guests