[Issue 13000] New: Casts should be removed to utilize features of inout
    via Digitalmars-d-bugs 
    digitalmars-d-bugs at puremagic.com
       
    Fri Jun 27 13:04:17 PDT 2014
    
    
  
https://issues.dlang.org/show_bug.cgi?id=13000
          Issue ID: 13000
           Summary: Casts should be removed to utilize features of inout
           Product: D
           Version: D2
          Hardware: x86
                OS: All
            Status: NEW
          Severity: normal
          Priority: P1
         Component: Phobos
          Assignee: nobody at puremagic.com
          Reporter: schveiguy at yahoo.com
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.
--
    
    
More information about the Digitalmars-d-bugs
mailing list