www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 11006] New: Subtraction of pinters for `void` and non-void types compiles

reply d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=11006

           Summary: Subtraction of pinters for `void` and non-void types
                    compiles
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Keywords: accepts-invalid
          Severity: major
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: verylonglogin.reg gmail.com



12:00:57 MSD ---
According to docs:
"For -, the pointers are subtracted and the result is divided by the size of
the type pointed to by the operands. It is an error if the pointers point to
different types."

Both passes (giving unexpected results) but should reject to compile:
---
static assert(cast(void*) 8 - cast(int*) 0 == 2);
static assert(cast(int*) 8 - cast(void*) 0 == 8);
---

Looks like a high danger for generic code.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Sep 10 2013
parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=11006


Andrej Mitrovic <andrej.mitrovich gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |andrej.mitrovich gmail.com
            Summary|Subtraction of pinters for  |Subtraction of pointers for
                   |`void` and non-void types   |`void` and non-void types
                   |compiles                    |compiles



13:38:29 PDT ---
Fixed typo.

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