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

Recursize unsized types cause ICE #23524

Closed
jamii opened this issue Mar 19, 2015 · 3 comments
Closed

Recursize unsized types cause ICE #23524

jamii opened this issue Mar 19, 2015 · 3 comments
Labels
I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️

Comments

@jamii
Copy link

jamii commented Mar 19, 2015

http://is.gd/o35wcP

Expected: Not sure, maybe some error about fat pointers growing unboundedly.

Actual: Uncommenting either line results in ICE.

What I am trying to achieve is something like:

struct Node: {
  population: u16,
  children: [Option<Node>; popcount(population)]
}

This general pattern (lengths depending on prior values) is useful for building data structures. It does not seem to be covered by DST and otherwise requires unsafe.

@steveklabnik steveklabnik added the I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ label Mar 19, 2015
@frewsxcv
Copy link
Member

Visiting for triage: this is still an issue

bltavares added a commit to bltavares/glacier that referenced this issue Oct 31, 2015
@apasel422
Copy link
Contributor

Triage: Still an issue.

@Mark-Simulacrum
Copy link
Member

Changing the code to not use unsized enums which currently aren't supported fixes this ICE. Since this no longer ICE's, I'm going to close.

struct Tree(u16, [Option<Box<Tree>>]);

struct Node<T: ?Sized> {
    population: u16,
    children: T,
}

struct Tree2(Node<Tree>);

fn main() {
    use std::mem::size_of;
    use std::sync::atomic;
    println!("{:?}", size_of::<&Tree>());
    println!("{:?}", size_of::<&Tree2>());
}
rustc 1.19.0-nightly (2d4ed8e0c 2017-05-03)
warning: field is never used: `population`
 --> <anon>:4:5
  |
4 |     population: u16,
  |     ^^^^^^^^^^^^^^^
  |
  = note: #[warn(dead_code)] on by default

warning: field is never used: `children`
 --> <anon>:5:5
  |
5 |     children: T,
  |     ^^^^^^^^^^^
  |
  = note: #[warn(dead_code)] on by default

warning: unused import: `std::sync::atomic`
  --> <anon>:12:9
   |
12 |     use std::sync::atomic;
   |         ^^^^^^^^^^^^^^^^^
   |
   = note: #[warn(unused_imports)] on by default

16
16

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️
Projects
None yet
Development

No branches or pull requests

5 participants