Skip to content

Segfault when calling Take<Take<Repeat<T>>>::count for certain T #74

@autumnontape

Description

@autumnontape

The following function segfaults when compiled at opt-level 2 or 3:

fn segfaults() -> usize {
    core::iter::repeat(()).take(1).take(1).count()
}

The Compiler Explorer output is here. You can see it produces this very strange line of assembly at the beginning of the function:

mov     rdx, QWORD PTR ds:0

GDB confirms that this is where the segfault occurs.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions