www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 1088] New: structs allocated with a struct allocator will not have default initializer values assigned

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

           Summary: structs allocated with a struct allocator will not have
                    default initializer values assigned
           Product: D
           Version: 1.010
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: major
          Priority: P2
         Component: DMD
        AssignedTo: bugzilla digitalmars.com
        ReportedBy: guido grumpy-cat.com


/* 
 * dmd -w -O dtest.d
 * ./dtest
 * static_foo.a = 800
 * dynamic_foo.a = 100
 */
import std.stdio;

int storage = 100;

struct foo {
        new(uint size, void* p) {
                return p;
        }

        int a = 800;
}

void main() {
        foo static_foo;
        writefln("static_foo.a = %d", static_foo.a);

        foo* dynamic_foo = new(&storage) foo;
        writefln("dynamic_foo.a = %d", dynamic_foo.a);
}


-- 
Mar 31 2007
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=1088





------- Comment #1 from thomas-dloop kuehne.cn  2007-04-04 15:36 -------
Added to DStress as
http://dstress.kuehne.cn/run/s/struct_initialization_10_A.d
http://dstress.kuehne.cn/run/s/struct_initialization_10_B.d


-- 
Apr 04 2007
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=1088


Andrei Alexandrescu <andrei metalanguage.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |andrei metalanguage.com
            Version|1.010                       |D1


--- Comment #2 from Andrei Alexandrescu <andrei metalanguage.com> 2011-01-08
13:03:56 PST ---
D1 only - D2 will eliminate custom operator new.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jan 08 2011