Bug 11440 – struct initialization with partially initialized data crashes

Status
NEW
Severity
normal
Priority
P3
Component
dmd
Product
D
Version
D2
Platform
x86_64
OS
Linux
Creation time
2013-11-04T11:22:54Z
Last change time
2024-12-13T18:13:40Z
Assigned to
No Owner
Creator
Daniel Davidson
Moved to GitHub: dmd#18708 →

Comments

Comment #0 by dbdavidson — 2013-11-04T11:22:54Z
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.
Comment #1 by mk — 2013-11-04T13:11:15Z
Can't reproduce both on Linux and Windows x86.
Comment #2 by burg.basile — 2013-11-04T15:09:34Z
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.
Comment #3 by burg.basile — 2013-11-04T15:29:24Z
(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/*}
Comment #4 by k.hara.pg — 2013-11-04T18:32:33Z
http://forum.dlang.org/post/[email protected] > > 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).
Comment #5 by robert.schadek — 2024-12-13T18:13:40Z
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dmd/issues/18708 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB