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

stack overflow when trying to compile this code snippet #22773

Closed
flo-l opened this issue Feb 24, 2015 · 3 comments
Closed

stack overflow when trying to compile this code snippet #22773

flo-l opened this issue Feb 24, 2015 · 3 comments
Labels
A-associated-items Area: Associated items such as associated types and consts. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️

Comments

@flo-l
Copy link
Contributor

flo-l commented Feb 24, 2015

I'm on Fedora 21, x86_64.

pub struct A<I: Iterator> {
    iter: I,
    buf: Vec<I::Item>,
}

impl<I: Iterator> Iterator for A<I> where
    I: Iterator<Item=I::Item>
{
    fn next(&mut self) -> Option<I::Item> {
        None
    }
}

fn main() {}

Output:

$ rustc test.rs 

thread 'rustc' has overflowed its stack
Ungültiger Maschinenbefehl (Speicherabzug geschrieben)

(Sorry for the german 😆 )

You can also watch it fail with the playpen!

@steveklabnik steveklabnik added I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ A-associated-items Area: Associated items such as associated types and consts. labels Feb 25, 2015
@steveklabnik
Copy link
Member

not strictly an ICE but close enough

@flo-l
Copy link
Contributor Author

flo-l commented Feb 25, 2015

probably fixed by #22512, the commit message says it fixes a few stack overflows related to associated types. I'll recheck if this still crashes in two days or so when the patch is the nightly! ;)

@tamird
Copy link
Contributor

tamird commented Apr 22, 2015

No longer ICEs.

$ rustc main.rs
main.rs:7:22: 7:29 error: unsupported cyclic reference between types/traits detected
main.rs:7     I: Iterator<Item=I::Item>
                               ^~~~~~~
note: the cycle begins when computing the bounds for type parameter `I`...
note: ...which then again requires computing the bounds for type parameter `I`, completing the cycle.
error: aborting due to previous error

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

No branches or pull requests

3 participants