Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Strings don't get passed by value properly #116

Open
mkilgore opened this issue Jun 17, 2022 · 0 comments
Open

Strings don't get passed by value properly #116

mkilgore opened this issue Jun 17, 2022 · 0 comments
Labels
bug Something isn't working

Comments

@mkilgore
Copy link
Contributor

mkilgore commented Jun 17, 2022

In QB45, all three of these result in the string being passed by value to the sub rather than by reference, however in QB64 the original string is passed in all three cases:

foobar (a$)
foobar (a$ + "")
foobar a$ + ""

It seems like the main culprit is that the parens or modifications don't trigger the string to get copied, so in the end it just passes the regular qbs pointer.

In the case of adding + "", qbs_add() contains short circuiting logic that just returns one of the passed strings directly if the other is length zero. That's not necessarily an issue by itself, but it means string modifications are not a guarantee of getting a copy.

Reported on the forum here: https://qb64phoenix.com/forum/showthread.php?tid=559

@mkilgore mkilgore added the bug Something isn't working label Jun 17, 2022
@mkilgore mkilgore added this to Backlog in Backlog/In Progress Jun 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Development

No branches or pull requests

1 participant