• Print

Author Topic: ASC to read past a string's length in a SUB/FUNCTION call seg-faults [fixed*]  (Read 124 times)

DSMan195276

  • Hero Member
  • *****
  • Posts: 2068
  • Yes
    • Email
ASC to read past a string's length in a SUB/FUNCTION call seg-faults [fixed*]
« on: February 18, 2013, 09:13:15 PM »
Edit: This looks to be the same as an error reported a few months ago here: http://www.qb64.net/forum/index.php?topic=9978.0

Code: [Select]
Ch = CHR$(13)
foo STR$(ASC(ch$, 2)) + ch$

SUB foo (bar$)
PRINT bar$
END SUB

That code seg-faults in SDL and GL. It's not legal to do but it should create an error not a seg-fault. Using ASC to read past the end of a string creates an error if you do it anywhere else besides a SUB/FUNCTION call (From everything I've tested).

Matt
« Last Edit: April 05, 2013, 08:04:48 PM by Galleon »
"Cast your cares on the Lord and he will sustain you; he will never let the righteous be shaken" -- Psalm 55:22
QB64 Linux Installer

mcalkins

  • Hero Member
  • *****
  • Posts: 1297
    • qbasicmichael.com
    • Email
Re: Using ASC to read past a string's length in a SUB/FUNCTION call seg-faults
« Reply #1 on: February 18, 2013, 09:26:03 PM »
Is this a duplicate of:
http://www.qb64.net/forum/index.php?topic=9978.0
?

Regards,
Michael
The QBASIC Forum Community: http://www.network54.com/index/10167 Includes off-topic subforums.
QB64 Off-topic subforum: http://qb64offtopic.freeforums.org/

DSMan195276

  • Hero Member
  • *****
  • Posts: 2068
  • Yes
    • Email
Re: Using ASC to read past a string's length in a SUB/FUNCTION call seg-faults
« Reply #2 on: February 18, 2013, 09:31:25 PM »
Quote from: mcalkins on February 18, 2013, 09:26:03 PM
Is this a duplicate of:
http://www.qb64.net/forum/index.php?topic=9978.0
?

Yes I'd say so, sorry about that. I'll put a link to that at the top of my post here.

Matt
"Cast your cares on the Lord and he will sustain you; he will never let the righteous be shaken" -- Psalm 55:22
QB64 Linux Installer

mcalkins

  • Hero Member
  • *****
  • Posts: 1297
    • qbasicmichael.com
    • Email
Re: Using ASC to read past a string's length in a SUB/FUNCTION call seg-faults
« Reply #3 on: February 18, 2013, 09:38:57 PM »
That's fine. I'll think of it as confirmation. :-)

Regards,
Michael
The QBASIC Forum Community: http://www.network54.com/index/10167 Includes off-topic subforums.
QB64 Off-topic subforum: http://qb64offtopic.freeforums.org/

  • Print