Work On Issue 18172 - add scope to pointers in getopt to allow @safe#6281
Work On Issue 18172 - add scope to pointers in getopt to allow @safe#6281JackStouffer wants to merge 1 commit intodlang:masterfrom
Conversation
|
Thanks for your pull request, @JackStouffer! Bugzilla references
|
| } | ||
| } | ||
|
|
||
| version(DIP1000) |
There was a problem hiding this comment.
I'm not sure how we want to handle DIP1000 regressions, but we need a way to ensure things stay @safe
There was a problem hiding this comment.
But this unittest needs to be annotated with @safe when -dip1000 is passed and @system when it's not to prevent any DIP1000 regressions. #6278 Doesn't have a mechanism for that.
There was a problem hiding this comment.
Argh fair enough - there still might be issues as long as -deps compiles all unittests of its dependencies :/
Anyhow, for the time being #6278 (or similar could set DIP1000 by hand).
std/getopt.d
Outdated
| { | ||
| // allocate a new string so as to remove the | ||
| // scope restriction | ||
| string option = "" ~ opts[0]; |
There was a problem hiding this comment.
this is due to the fact that to!(string)(string) acts as a pass through.
aa2b739 to
23e191e
Compare
| static if (is(typeof(opts[0]) == string)) | ||
| { | ||
| // allocate a new string so as to remove the | ||
| // scope restriction |
There was a problem hiding this comment.
That really sucks. Safety shouldn't result in a performance overhead :/
Especially because in this case
getoptImpldoesn't store anything, but modifiesconfigurationandrslt- it's a GC allocated string
|
Here's an idea how to programmatically detect void main()
{
enum isDIP1000 = __traits(compiles, () @safe {
int x;
int* p;
p = &x;
});
pragma(msg, isDIP1000);
}normal: https://run.dlang.io/is/RID7vh Of course that could be fancier. (based on the recent forum thread: https://forum.dlang.org/post/ayemvxctmpqqsokbmqeb@forum.dlang.org) |
|
If people want to tackle the DIP1000 returning a struct issue, I'd be glad to see their solution. Until then, I'm closing this as this isn't going to go anywhere. |
No description provided.