[Issue 9904] New: typeof(null) can be casted to aggregate type if .sizeof equals size of pointer
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Mon Apr 8 07:42:23 PDT 2013
http://d.puremagic.com/issues/show_bug.cgi?id=9904
Summary: typeof(null) can be casted to aggregate type if
.sizeof equals size of pointer
Product: D
Version: D2
Platform: All
OS/Version: All
Status: NEW
Keywords: accepts-invalid
Severity: normal
Priority: P2
Component: DMD
AssignedTo: nobody at puremagic.com
ReportedBy: andrej.mitrovich at gmail.com
--- Comment #0 from Andrej Mitrovic <andrej.mitrovich at gmail.com> 2013-04-08 07:42:22 PDT ---
struct S1
{
int x;
}
struct S2
{
int x;
byte b;
}
void main()
{
static assert(S1.sizeof == typeof(null).sizeof);
auto s1 = cast(S1)null; // compiles, should not
static assert(S2.sizeof != typeof(null).sizeof);
auto s2 = cast(S2)null; // NG, as it should
}
--
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