core.stdc.stdlib: annotate with 'scope'#1749
Conversation
96d6f97 to
b5c1dba
Compare
|
Auto-merge toggled on |
src/core/stdc/stdlib.d
Outdated
| // strtold exists starting from VS2013, so we make this a template to avoid link errors | ||
| /// | ||
| real strtold()(in char* nptr, char** endptr) | ||
| real strtold()(scope inout(char)* nptr, inout(char)** endptr) |
There was a problem hiding this comment.
Fails on Win32_64 w/
std\conv.d(3163): Error: template core.stdc.stdlib.strtold cannot deduce function from argument types !()(string, typeof(null)), candidates are:
..\druntime\import\core\stdc\stdlib.d(109): core.stdc.stdlib.strtold()(scope inout(char)* nptr, inout(char)** endptr)
| c_long atol(scope const char* nptr); | ||
| /// | ||
| long atoll(in char* nptr); | ||
| long atoll(scope const char* nptr); |
There was a problem hiding this comment.
It was circulated for quite a while that in is supposed to mean scope const, in the compiler it was always just const but lots of people have used it as scope const. Have you thought about actually changing the semantic of in?
There was a problem hiding this comment.
b5c1dba to
fe160cb
Compare
| float strtof(scope inout(char)* nptr, scope inout(char)** endptr); | ||
| /// | ||
| c_long strtol(in char* nptr, char** endptr, int base); | ||
| c_long strtol(scope inout(char)* nptr, scope inout(char)** endptr, int base); |
There was a problem hiding this comment.
This seems to have broken the travis builds for dmd, e.g. https://travis-ci.org/dlang/dmd/jobs/201062823#L5271
The change seems ok, but it breaks code that tried to work around the wrong annotation. The problem with fixing dmd is that it is built with both dmd 2.073 and git-master...
There was a problem hiding this comment.
The error message:
mars.d(420): Error: function core.stdc.stdlib.strtol (scope inout(char)* nptr, scope inout(char)** endptr, int base) is not callable using argument types (const(char)*, char**, int)
This is the problem I was trying to correct. The old declaration allowed a const pointer to be converted to a mutable one. Any code that relies on such needs to be fixed.
There was a problem hiding this comment.
Sure. dmd doesn't rely on the old signature, it had to workaround it with a cast. See dlang/dmd#6539
There was a problem hiding this comment.
I suspect we need to readd the old signatures as deprecated, otherwise every other project will fail to compile.
|
It says |
For -dip1000. Also corrects problem where
strtoldcan be used to convert pointer to immutable to pointer to mutable.