Skip to content

for loops allow moving out of references #16205

Closed
@steveklabnik

Description

@steveklabnik

Updated description

for loops allow moving out of fixed size arrays. This code compiles and should not compile.

struct Foo {
    a: [Box<int>, ..3],
}

fn main() {
    let f = Foo { a: [box 3, box 4, box 5] };
    for &a in f.a.iter() {
    }
}

Original description

segfault with channels

I don't know how to make this test case smaller, but...

steveklabnik/dining_philosophers@52ca036

This commit introduces a segfault.

steve@computer:~/src/dining_philosophers$ cargo run
   Compiling dining_philosophers v0.0.1 (file:/home/steve/src/dining_philosophers)
     Running `target/dining_philosophers`
Baruch Spinoza has sat down to eat.
An unknown error occurred

To learn more, run the command again with --verbose.  
steve@computer:~/src/dining_philosophers$ ./target/dining_philosophers 
Karl Marx has sat down to eat.
Karl Marx is thinking.
Baruch Spinoza has sat down to eat.
Baruch Spinoza is thinking.
Segmentation fault (core dumped)
steve@computer:~/src/dining_philosophers$

Seems bad.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions