QB64.org Forum

Active Forums => QB64 Discussion => Topic started by: Cobalt on November 30, 2021, 11:41:45 am

Title: Has the issue with GET\PUT using Fixed Strings been addressed lately?
Post by: Cobalt on November 30, 2021, 11:41:45 am
So I can stop running into this:

In file included from qbx.cpp:2185:
..\\temp\\main.txt: In function 'void SUB_SAVE_IT(qbs*)':
..\\temp\\main.txt:3329:137: error: lvalue required as unary '&' operand
 sub_put(qbr(*_SUB_SAVE_IT_SINGLE_F),NULL,byte_element((uint64)(&(qbs_new_fixed(&((uint8*)(__ARRAY_STRING255_DIALOGS[0]))[(0)*255],255,1))),(255*(__ARRAY_STRING255_DIALOGS[2]&1)*__ARRAY_STRING255_DIALOGS[5])-(255*(0)),byte_element_118),0);
compilation terminated due to -Wfatal-errors.

Title: Re: Has the issue with GET\PUT using Fixed Strings been addressed lately?
Post by: SpriggsySpriggs on November 30, 2021, 11:53:21 am
I think @SMcNeill had mentioned it several months ago with a possible fix but I think it broke other things.
Title: Re: Has the issue with GET\PUT using Fixed Strings been addressed lately?
Post by: FellippeHeitor on November 30, 2021, 12:04:25 pm
You don't mention what version of QB64 you're using there, Cobalt. Is it the latest?
Title: Re: Has the issue with GET\PUT using Fixed Strings been addressed lately?
Post by: FellippeHeitor on November 30, 2021, 12:06:38 pm
Also, if you can, please provide a minimal reproducible sample snippet we can use to check the issue.
Title: Re: Has the issue with GET\PUT using Fixed Strings been addressed lately?
Post by: SpriggsySpriggs on November 30, 2021, 12:17:47 pm
It's been discussed before a few times, looks like:
https://www.qb64.org/forum/index.php?topic=3974.msg133138#msg133138 (https://www.qb64.org/forum/index.php?topic=3974.msg133138#msg133138)
https://www.qb64.org/forum/index.php?topic=3347.msg126452#msg126452 (https://www.qb64.org/forum/index.php?topic=3347.msg126452#msg126452)
https://www.qb64.org/forum/index.php?topic=1471.msg106707#msg106707 (https://www.qb64.org/forum/index.php?topic=1471.msg106707#msg106707)
Title: Re: Has the issue with GET\PUT using Fixed Strings been addressed lately?
Post by: FellippeHeitor on November 30, 2021, 12:40:33 pm
That's a good example of why reporting issues in the forum alone and not creating an issue in the repository is prone to leave bugs behind.

https://github.com/QB64Team/qb64/issues/new/choose
Title: Re: Has the issue with GET\PUT using Fixed Strings been addressed lately?
Post by: Cobalt on November 30, 2021, 01:32:13 pm
You don't mention what version of QB64 you're using there, Cobalt. Is it the latest?

Well it was more of an open-ended question. but yes latest build(stable) 2.0.2

Code: QB64: [Select]
  1. DIM A(255) AS STRING * 255
  2.  
  3. OPEN "TEST.TXT" FOR BINARY AS #1
  4.  
  5. PUT #1, , A() 'GET #1 causes the same issue
  6.  
  7.  

That's a good example of why reporting issues in the forum alone and not creating an issue in the repository is prone to leave bugs behind.

But you know how much GIT loves me. *sarcasm sarcasm*
I will see if it will allow me to though.

It's been discussed before a few times, looks like:

That is true, but yet no definitive repair was presented. And while the simple FOR\NEXT approach works, its just an inconvenience to have to when other data types don't need such excess code to be saved or read.
Title: Re: Has the issue with GET\PUT using Fixed Strings been addressed lately?
Post by: SpriggsySpriggs on November 30, 2021, 02:51:25 pm
Yeah, like I was saying; I know Steve had discussed a fix in the C++ code but I don't think it was going to work out in the long term. I want to say I've seen Luke talk about it in the Discord as well but I don't know what ended up happening with that.
Title: Re: Has the issue with GET\PUT using Fixed Strings been addressed lately?
Post by: SMcNeill on November 30, 2021, 03:00:51 pm
Aye.  You can go in and alter the translated code in internal/temp manually with my "fix", but we can't push it into the repo as it breaks other things if applied across the board.  If I could sort out where in QB64 we generate the appropriate code for the c translation, I could probably write an IF condition to toggle translation between the two outputs, but I haven't had time (or honestly, motivation) to try and dig deep into the internals and push for the issue.

And for those who don't understand WHY this is such a complex bug to sort out, here's one  of the machine translated PUT statements:

sub_put( 1 , 1 ,byte_element((uint64)(&(qbs_new_fixed(&((uint8*)(__ARRAY_STRING1_B[0]))[(0)*1],1,1))),(1*(__ARRAY_STRING1_B[2]&1)*__ARRAY_STRING1_B[5])-(1*(0)),byte_element_1),1);

The issue is with a stray & in there.  Oddly enough, from what I remember with the issue, removing it fixes so we can PUT #1, , array(), but it breaks PUT #1, , array(element), which we can do now.

Which is why their needs to be a toggle in the output, but I'll be damned if I can sort out where to PUT it inside QB64's internals.
Title: Re: Has the issue with GET\PUT using Fixed Strings been addressed lately?
Post by: Cobalt on November 30, 2021, 10:09:48 pm
Is now a GItHub Issue.

#211
Title: Re: Has the issue with GET\PUT using Fixed Strings been addressed lately?
Post by: George McGinn on November 30, 2021, 11:09:33 pm
I posted a reply on GIT, but I wanted to place it here, just in case putting it in GIT was the wrong place to do so.

The code below does what you want it to, just replace the BINARY and PUT with OUTPUT and PRINT.

Code: QB64: [Select]
  1. DIM A(255) AS STRING * 255
  2. OPEN "File.tmp" FOR OUTPUT AS #1
  3. FOR I = 1 TO 255
  4.     B$ = ""
  5.     FOR Z = 1 TO 255
  6.         B$ = B$ + "A"
  7.     NEXT Z
  8.     B$ = B$ + "ZZZZZ"
  9.     A(I) = B$
  10.     PRINT #1, A(I)
Title: Re: Has the issue with GET\PUT using Fixed Strings been addressed lately?
Post by: TempodiBasic on December 05, 2021, 12:51:05 pm
@SMcNeill
It is very impressive how so far from human language is that translation!
So our translator into C++ is not a real translator to pure C++ but a script writer that translate QB64 code into script calling  BAS. CPP library.

I hope and pray for all you developers that Rob has left you a map of his library.
It is hard to walk blind in the city!
Good luck boys.