Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

struct initialization with partially initialized data crashes #18708

Open
dlangBugzillaToGithub opened this issue Nov 4, 2013 · 4 comments
Open
Labels

Comments

@dlangBugzillaToGithub
Copy link

Daniel Davidson reported this on 2013-11-04T11:22:54Z

Transferred from https://issues.dlang.org/show_bug.cgi?id=11440

CC List

  • Martin Krejcirik

Description

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.
@dlangBugzillaToGithub
Copy link
Author

mk commented on 2013-11-04T13:11:15Z

Can't reproduce both on Linux and Windows x86.

@dlangBugzillaToGithub
Copy link
Author

burg.basile commented on 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.

@dlangBugzillaToGithub
Copy link
Author

burg.basile commented on 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/*}

@dlangBugzillaToGithub
Copy link
Author

k.hara.pg commented on 2013-11-04T18:32:33Z

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).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant