[Issue 7021] Structs with disabled default constructors can be constructed without calling a constructor.
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Mon Sep 24 06:31:07 PDT 2012
http://d.puremagic.com/issues/show_bug.cgi?id=7021
Don <clugdbug at yahoo.com.au> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |clugdbug at yahoo.com.au
--- Comment #15 from Don <clugdbug at yahoo.com.au> 2012-09-24 06:31:57 PDT ---
(In reply to comment #13)
> (In reply to comment #12)
> > For structs, as long as there is no static opCall declared, S() and S.init
> > should be identical,
>
> This is not already true for nested structs.
>
> void main() {
> int g = 10;
> struct S {
> int n;
> auto foo(){ return g; }
> }
> auto s1 = S(); // StructLiteralExp
> assert(s1.tupleof[$-1] !is null); // hidden ptr is filled
> assert(s1.foo() == 10); // OK
> auto s2 = S.init;
> assert(s2.tupleof[$-1] is null); // hidden ptr isn't filled
> assert(s2.foo() == 10); // Access Violation!
> }
That's a bug: .init for nested structs is garbage. It's the cause of bug 6419,
for example. defaultInitLiteral() is wrong.
--
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