rust icon indicating copy to clipboard operation
rust copied to clipboard

Segfault from using casted trait

Open 14427 opened this issue 13 years ago • 5 comments

Updated Test Case (warning: may not be faithful to the original problem)

use core::io::ReaderUtil;
use core::io::Reader;

fn foo(r:@Reader) -> ~str { r.read_line() }
fn baz<R:Reader>(r:R) -> ~str { r.read_line() }
fn waz<R:ReaderUtil>(r:R) -> ~str { r.read_line() }

fn main() {
    let _m = foo(io::stdin());
    let _m = baz(io::stdin());
    let _m = waz(io::stdin());
}

Original Report

The following code compiles, but causes a segmentation fault when run:

let stdin = io::stdin() as &io::ReaderUtil;
let _m = stdin.read_line();

This is using master on Ubuntu.

14427 avatar Jan 02 '13 18:01 14427

I'll look at this, since I was working on something similar.

catamorphism avatar Jan 03 '13 20:01 catamorphism

I cannot duplicate this on Mac OS X.

pnkfelix avatar Mar 25 '13 19:03 pnkfelix

Note that in my comment above, I was testing against an "updated" version of the code that may not be faithful to the original bug scenario. But if that is the case, it may also be the case that this bug has gone away with type-checker changes since it was filed...

pnkfelix avatar Mar 25 '13 19:03 pnkfelix

Seems to be fixed; pending #5619 for the test case. (I chose to add the original test case, except with stdin changed to stdout so we don't have a test case reading input, for fidelity to the original bug.)

catamorphism avatar Mar 29 '13 02:03 catamorphism

Test case merged in 318d926 - closing

catamorphism avatar Apr 01 '13 18:04 catamorphism