Coder Social home page Coder Social logo

Comments (10)

gurry avatar gurry commented on May 30, 2024 1

Thanks @compiler-errors. Just want to add that some other intrinsics also ICE.

For example:

fn main() {
    read_via_copy();
}

extern "rust-intrinsic" fn read_via_copy() {}

ICEs as well.

from rust.

compiler-errors avatar compiler-errors commented on May 30, 2024

Please try to minimize the example as much as possible:

fn main() {
    transmute();
}

extern "rust-intrinsic" fn transmute() {}

from rust.

gurry avatar gurry commented on May 30, 2024

@rustbot claim

from rust.

compiler-errors avatar compiler-errors commented on May 30, 2024

@gurry: heads up that @estebank already put up a fix

from rust.

compiler-errors avatar compiler-errors commented on May 30, 2024

Interesting @gurry -- I wonder if we should perhaps fix this in a less specific way than #123526. I wonder if we should instead detect that the extern "rust-intrinsic" declaration is not valid b/c feature(intrinsics) has not been enabled in the crate...

If not, then I'd be glad to review a PR that fixes whatever other intrinsics you find to make too many assumptions in the compiler.

from rust.

gurry avatar gurry commented on May 30, 2024

I wonder if we should instead detect that the extern "rust-intrinsic" declaration is not valid b/c feature(intrinsics) has not been enabled in the crate...

Even adding feature(intrinsics) does not prevent the ICE unfortunately.

It happens in lower_intrinsics.rs due to the wrong number of arguments e.g. here for read_via_copy:

let [arg] = args.as_slice() else {
span_bug!(terminator.source_info.span, "Wrong number of arguments");
};

span_bug!(..., "Wrong number of arguments...") occurs for a lot of intrinsics in this file. I'm guessing all of them will ICE under the conditions in this issue.

To fix it, we could extend what's done for transmute in #123526 to all intrinsics, maybe leveraging this code to know how many args are expected for any given intrinsic:

let (n_tps, n_cts, inputs, output) = match intrinsic_name {

from rust.

gurry avatar gurry commented on May 30, 2024

I have opened #123587

from rust.

gurry avatar gurry commented on May 30, 2024

Looks like intrinsics are expected to ICE if used wrongly (see comment: #123587 (comment)) so #123587 I opened has been rightly closed.

But that mean that transmute should also ICE in these conditions. However, in the present issue it was ICEing for the wrong reason i.e. out of bound access . So #123526 does the right thing by stopping that. However, IMHO it should not taint the context and let it go to MIR lowering and then let it ICE there. That keeps transmute consistent with other intrinsics' behaviour as noted above.

Thoughts @estebank & @compiler-errors? If you guys agree I can open a PR to remove the tainting.

from rust.

compiler-errors avatar compiler-errors commented on May 30, 2024

See #123603 which takes a different approach

from rust.

gurry avatar gurry commented on May 30, 2024

Nice!

from rust.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.