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

Corrupted initialization in the static struct #5688

Closed
lifthrasiir opened this issue Apr 3, 2013 · 5 comments
Closed

Corrupted initialization in the static struct #5688

lifthrasiir opened this issue Apr 3, 2013 · 5 comments
Labels
E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added.

Comments

@lifthrasiir
Copy link
Contributor

struct X { vec: &'static [int] }
static V: &'static [X] = &[X { vec: &[1, 2, 3] }];
fn main() {
    for V.each |&v| {
        io::println(fmt!("%?", v.vec));
    }
}

...should print &[1, 2, 3] but instead prints something like &[4492532864, 24]. It is pretty evident that the compiler messed up with the representation of [int, ..n] and [int] somehow, or at least failed to typecheck correctly.

@ghost ghost assigned graydon Apr 3, 2013
@thestinger
Copy link
Contributor

@graydon: this looks similar to the static array problem you were dealing with before

@graydon
Copy link
Contributor

graydon commented Apr 3, 2013

Does, yes. But I pushed a fix last week. Can you reproduce on incoming?

@lifthrasiir
Copy link
Contributor Author

@graydon I've tested the code with the recent master (5f13e9c 2013-04-02 13:36:51 -0700). I see dozens of commits in between but clearly the master itself is very new.

@alexcrichton
Copy link
Member

Reproduced with 84233c0 on 2013-05-20 09:34:44 -0700

@alexcrichton
Copy link
Member

This code now works:

struct X { vec: &'static [int] }
static V: &'static [X] = &[X { vec: &[1, 2, 3] }];
fn main() {
    for &v in V.iter() {
        println(fmt!("%?", v.vec));
    }
}

Flagging as needstest.

@huonw huonw closed this as completed in 12099ce Sep 3, 2013
flip1995 pushed a commit to flip1995/rust that referenced this issue Jun 5, 2020
…p1995

Fix cargo tests when running inside the rustlang/rust repo

It seems we hit rust-lang/cargo#5418, so I've applied the suggested solution. Also added some more info when cargo-metadata fails to execute.

(there was no open issue for this)

changelog: none
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added.
Projects
None yet
Development

No branches or pull requests

4 participants