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

Some recursive definitions of structs/enums cause compiler to hang #33467

Closed
harveyadcock opened this issue May 6, 2016 · 3 comments
Closed

Comments

@harveyadcock
Copy link

The following code causes the compiler to loop indefinitely (until the system runs out of memory):

enum Node {
    Branch(Branch),
    Leaf(Leaf)
}

struct Branch {
    value: i32,
    left: Node,
    right: Node
}

struct Leaf {
    value: i32
}

This seems to be a failure of the compiler to recognise when a struct/enum would be infinite in size, interestingly commenting out one of the Nodes (either left or right in Branch) allows the compiler to identify an infinite recursion and give the appropriate error message.

@jonas-schievink
Copy link
Contributor

Duplicate of #32619, #32326, #33180

@harveyadcock
Copy link
Author

harveyadcock commented May 6, 2016

Ah, clearly my previous bug searching is pretty poor, apologies!

@nagisa
Copy link
Member

nagisa commented May 6, 2016

Closing.

@nagisa nagisa closed this as completed May 6, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants