Bug 13000 – Casts should be removed to utilize features of inout
Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P1
Component
phobos
Product
D
Version
D2
Platform
All
OS
All
Creation time
2014-06-27T20:04:00Z
Last change time
2014-06-28T18:26:24Z
Keywords
pull
Assigned to
nobody
Creator
schveiguy
Comments
Comment #0 by schveiguy — 2014-06-27T20:04:17Z
In Pull request https://github.com/D-Programming-Language/phobos/pull/2272, it was discovered that some functions in phobos had incorrectly applied inout to the return type, and to get around the compiler complaints, used casts.
A dummy example:
class X
{
int x;
inout int *foo() inout
{
return cast(int *)&x;
}
}
The point of this was to try and apply inout to the return value, but the left-hand side inout was redundant.
The fix is to remove the cast, and properly apply inout as:
inout(int)* foo() inout
The above-mentioned pull removed the left-most inout, which fixes the redundancy (required by a new DMD change), but we should fix the cast properly. See the pull request for the locations that were changed.