Skip to content

Bad behaviour with break in while-loop condition #21751

Closed
@arielb1

Description

@arielb1

If you put a break in the condition of a while-loop, the compiler code seems to exhibit undefined behaviour.

For example, in play.rust-lang.org, this SIGILL-s when -O0 and prints 5 blank lines when -O2:

fn main() {
    for _ in 0..5 {
        while { break; } { println!("never"); }
        println!("?");
    }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    I-crashIssue: The compiler crashes (SIGSEGV, SIGABRT, etc). Use I-ICE instead when the compiler panics.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions