This repository was archived by the owner on Oct 12, 2022. It is now read-only.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Adding
scopewill allow passing pointers to local variables in@safecode. See also #1740, #1748 and #1749.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, that's a new one ;-). I'll look into it and add it, thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I obviously need to do a reading on DIP 1000. I've updated the PR, but this question is making me wonder:
Moving
char[100] bufouside of a scope works.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using DMD 2.073.0 and compiling with
-dip1000I got the following results:(same result as yours)
So while DIP1000 is not a 100% solution (yet), using
scopeis still an improvement for@safecode, because it allows to pass pointers to some local variables.Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just saw the forum post (thanks for bringing this to Walter's attention) and I was wondering if we should change the declarations to:
relying on the fact that the calling convention should remain the same. @WalterBright do you think this is a good idea?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ping @WalterBright
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No,
scope char** lineptris correct here, the function doesn't escape the value of thechar**pointer passed in. In any case it hardly seems to matter b/c those functions are inherently unsafe, after the call*lineptrwill point to some internal buffer of the stream.