www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 13000] New: Casts should be removed to utilize features of

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 puremagic.com
          Reporter: schveiguy 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.

--
Jun 27 2014