[Issue 11006] New: Subtraction of pinters for `void` and non-void types compiles
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Tue Sep 10 01:00:58 PDT 2013
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 at puremagic.com
ReportedBy: verylonglogin.reg at gmail.com
--- Comment #0 from Denis Shelomovskij <verylonglogin.reg at gmail.com> 2013-09-10 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: -------
More information about the Digitalmars-d-bugs
mailing list