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

Infinite recursion for enum variant defined in terms of itself #23302

Closed
huonw opened this issue Mar 12, 2015 · 1 comment
Closed

Infinite recursion for enum variant defined in terms of itself #23302

huonw opened this issue Mar 12, 2015 · 1 comment
Labels
I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️

Comments

@huonw
Copy link
Member

huonw commented Mar 12, 2015

enum X { A = X::A as isize }

fn main() {}
thread 'rustc' has overflowed its stack
Illegal instruction (core dumped)
@huonw huonw added the I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ label Mar 12, 2015
@frewsxcv
Copy link
Member

Can confirm this is still an issue in Rust 1.0 beta 2

~/Downloads $ rustc test.rs

thread 'rustc' has overflowed its stack
fish: Job 1, 'rustc test.rs ' terminated by signal SIGILL (Illegal instruction)

~/Downloads $ rustc --version
rustc 1.0.0-beta.2 (e9080ec39 2015-04-16) (built 2015-04-16)

quantheory added a commit to quantheory/rust that referenced this issue Jun 23, 2015
bors added a commit that referenced this issue Jul 9, 2015
Fixes #23302.

Note that there's an odd situation regarding the following, most likely due to some inadequacy in `const_eval`:

```rust
enum Y {
    A = 1usize,
    B,
}
```

In this case, `Y::B as usize` might be considered a constant expression in some cases, but not others.  (See #23513, for a related problem where there is only one variant, with no discriminant, and it doesn't behave nicely as a constant expression either.)

Most of the complexity in this PR is basically future-proofing, to ensure that when `Y::B as usize` is fully made to be a constant expression, it can't be used to set `Y::A`, and thus indirectly itself.
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

2 participants