www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 11440] New: struct initialization with partially initialized data crashes

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

           Summary: struct initialization with partially initialized data
                    crashes
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: dbdavidson yahoo.com


--- Comment #0 from Daniel Davidson <dbdavidson yahoo.com> 2013-11-04 11:22:54
PST ---
import std.stdio;

struct Y {
  private immutable(int)[] _data;
}

struct CFS {
  double x = 5;
  Y growth;
}

void main() {
  auto s = CFS(1.0);      // crash
  //auto s = CFS(1, Y()); // crash
  //auto s = CFS(1, Y([])); // works
  writeln(s);
}

If x is an int there is no problem.
If s is not accessed there is no problem, so it dies in the writeln call.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Nov 04 2013
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=11440


Martin Krejcirik <mk krej.cz> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |mk krej.cz


--- Comment #1 from Martin Krejcirik <mk krej.cz> 2013-11-04 22:11:15 CET ---
Can't reproduce both on Linux and Windows x86.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Nov 04 2013
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=11440


burg.basile yahoo.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |burg.basile yahoo.com


--- Comment #2 from burg.basile yahoo.com 2013-11-04 15:09:34 PST ---
import std.stdio;

struct Y {
  private
    immutable(int)[] _data;
    immutable(int)[] _data2;
}

struct CFS {
  double x = 5;
  Y growth;
}

void main() {
  auto s = CFS(1.0);
  writeln(s);
}

runs.

It seems to be more related to the the "private" token.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Nov 04 2013
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=11440



--- Comment #3 from burg.basile yahoo.com 2013-11-04 15:29:24 PST ---
(In reply to comment #2)
 import std.stdio;
 
 struct Y {
   private:
     immutable(int)[] _data;
     immutable(int)[] _data2;
 }
 
 struct CFS {
   double x = 5;
   Y growth;
 }
 
 void main() {
   auto s = CFS(1.0);
   writeln(s);
 }
 
 runs.
 
 It seems to be more related to the the "private" token.
EDIT: BTW either with private: or private{*/two or more declarations/*} -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Nov 04 2013
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=11440


Kenji Hara <k.hara.pg gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Platform|All                         |x86_64
         OS/Version|All                         |Linux


--- Comment #4 from Kenji Hara <k.hara.pg gmail.com> 2013-11-04 18:32:33 PST ---
http://forum.dlang.org/post/nlyjuddqfpdkwfkalxax forum.dlang.org

 It doesn't happen with -O, or when compiled with LDC or GDC.
And it doesn't happen when building with -m32 (I'm on x86_64 linux).
-- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Nov 04 2013