Skip to content

ICE in trans::type_of::in_memory_type_of from Option<str> in FFI #25637

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Closed
geofft opened this issue May 20, 2015 · 1 comment
Closed

ICE in trans::type_of::in_memory_type_of from Option<str> in FFI #25637

geofft opened this issue May 20, 2015 · 1 comment
Labels
A-DSTs Area: Dynamically-sized types (DSTs) I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️

Comments

@geofft
Copy link
Contributor

geofft commented May 20, 2015

The following code ICEs in nightly on play.rust-lang.org, as well as in 1.0 stable:

extern {
    fn foo(x: Option<str>);
}
fn main() {
}
<anon>:2:15: 2:26 warning: found type without foreign-function-safe representation annotation in foreign module, consider adding a #[repr(...)] attribute to the type, #[warn(improper_ctypes)] on by default
<anon>:2     fn foo(x: Option<str>);
                       ^~~~~~~~~~~
<anon>:2:5: 2:28 warning: foreign function is never used: `foo`, #[warn(dead_code)] on by default
<anon>:2     fn foo(x: Option<str>);
             ^~~~~~~~~~~~~~~~~~~~~~~
error: internal compiler error: unexpected panic
note: the compiler unexpectedly panicked. this is a bug.
note: we would appreciate a bug report: https://github.com/rust-lang/rust/blob/master/CONTRIBUTING.md#bug-reports
note: run with `RUST_BACKTRACE=1` for a backtrace
thread 'rustc' panicked at 'Unexpected type returned from struct_tail: core::option::Option<str> for ty=core::option::Option<str>', /home/rustbuild/src/rust-buildbot/slave/nightly-dist-rustc-linux/build/src/librustc_trans/trans/type_of.rs:354

Between this and #25581, I'm increasingly believing that Rust should firmly disallow non-C-compatible types in extern functions, not merely lint on them. extern "C" means to use the C ABI, and there is no C ABI support for passing slices, strs, etc. around.

@huonw huonw added I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ A-DSTs Area: Dynamically-sized types (DSTs) labels May 20, 2015
@arielb1
Copy link
Contributor

arielb1 commented May 20, 2015

Duplicate of #25388.

arielb1 added a commit to arielb1/rust that referenced this issue May 22, 2015
arielb1 added a commit to arielb1/rust that referenced this issue May 23, 2015
arielb1 pushed a commit to arielb1/rust that referenced this issue Jul 9, 2015
Fixes rust-lang#25637

this is of course a [breaking-change] to these who relied on it
arielb1 pushed a commit to arielb1/rust that referenced this issue Jul 9, 2015
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
A-DSTs Area: Dynamically-sized types (DSTs) I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️
Projects
None yet
Development

No branches or pull requests

4 participants