www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 2434] New: Compiler generates code that does not pass with -w for some array operations

reply d-bugmail puremagic.com writes:

           Summary: Compiler generates code that does not pass with -w for
                    some array operations
           Product: D
           Version: 1.036
          Platform: PC
        OS/Version: Windows
            Status: NEW
          Keywords: rejects-valid
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: bugzilla digitalmars.com
        ReportedBy: jarrett.billingsley gmail.com

T[] a = [1, 2, 3, 4, 5];
a[] = 1 op a;

Replace T with byte, ubyte, short, or ushort.  Replace op with / or %.  For

byte[] a = [1, 2, 3, 4, 5];
a[] = 1 / a;

All possible combinations give errors like this when -w is enabled:

warning - Error: implicit conversion of expression (cast(int)c0 /
cast(int)(p1[p])) of type int to byte can cause loss of data

The c0, p1, and p variables are what the compiler uses for internal names when
converting array operations into code, so this is an error in the generated

Similar things happen if you have something like:

T[] b = [1, 2, 3, 4, 5];
a[] = b[] op a[];

Oct 28 2008
parent d-bugmail puremagic.com writes:

yebblies <yebblies gmail.com> changed:

           What    |Removed                     |Added
             Status|NEW                         |RESOLVED
                 CC|                            |yebblies gmail.com
         Resolution|                            |FIXED

--- Comment #1 from yebblies <yebblies gmail.com> 2011-06-10 05:07:30 PDT ---
Currently dmd (1.068 and 2.052) fails to compile these with the following

testx.d(4): Error: incompatible types for ((1) / (a)): 'int' and 'byte[]'

Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jun 10 2011