[Issue 8752] New: Unsafe use of T.init should be allowed in @system function
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Thu Oct 4 05:08:57 PDT 2012
http://d.puremagic.com/issues/show_bug.cgi?id=8752
Summary: Unsafe use of T.init should be allowed in @system
function
Product: D
Version: D2
Platform: All
OS/Version: All
Status: NEW
Severity: enhancement
Priority: P2
Component: DMD
AssignedTo: nobody at puremagic.com
ReportedBy: k.hara.pg at gmail.com
--- Comment #0 from Kenji Hara <k.hara.pg at gmail.com> 2012-10-04 05:03:01 PDT ---
I think that T.init should be always legal expression for any T.
But, I also agree that T.init _sometimes_ *unsafe*.
1) If T has @disable this(), T.init will returns an object which just
initialized (== the value itself is never undefined), but not
constructed (might be logically invalid object).
2) If T is nested struct, it's frame pointer is always null. It might
cause access violation by its member function call.
To relax the dilemma, I'd like to propose following restriction which enforced
by the compiler.
If T.init is unsafe (T is nested struct, or has @disable this();) , it will be
annotated with @system, then could use it only inside @system and @trusted
functions.
--
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