www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 20678] New: Integral deprecation should not trigger on valid


          Issue ID: 20678
           Summary: Integral deprecation should not trigger on valid code
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: pro.mathias.lang gmail.com

The current rule for triggering the integral deprecation message are way too
lax and intrusive...
The following is perfectly valid:
struct BitField
    private ushort[] data;
    private enum BitsPerT = (ushort.sizeof * 8);

    public bool opIndexAssign (bool value, size_t index)
        if (!value)
            this.data[index / BitsPerT] &= ~mask(index); // HERE
        return value;

    static ushort mask (size_t index)
        return (1 << ( BitsPerT - 1 - (index % BitsPerT)));

But it forces the user to insert a dumb cast on the line annotated with `//
This can be seen in https://issues.dlang.org/show_bug.cgi?id=19614

Mar 16 2020