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



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



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



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





 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



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