Skip to content

LLVM failure compiling borrow #3026

New issue

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

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

Already on GitHub? Sign in to your account

Closed
nikomatsakis opened this issue Jul 26, 2012 · 4 comments
Closed

LLVM failure compiling borrow #3026

nikomatsakis opened this issue Jul 26, 2012 · 4 comments
Assignees
Labels
A-codegen Area: Code generation A-lifetimes Area: Lifetimes / regions I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️
Milestone

Comments

@nikomatsakis
Copy link
Contributor

An LLVM failure results from compiling this program:

use std;
import std::map::hashmap;
import std::map;

fn main() {
    let buggy_map :hashmap<uint, &uint> = hashmap::<uint, &uint>(uint::hash, uint::eq);
    let x = ~1;
    buggy_map.insert(42, x);
}
@jruderman
Copy link
Contributor

Still crashes if I eliminate the "implicit copy" warning, by replacing x in the arg list with

~*x

or

~1

(is there a better way to silence the warning?)

Assertion failed: (getOperand(0)->getType() == cast<PointerType>(getOperand(1)->getType())->getElementType() && "Ptr must be a pointer to Val type!"), function AssertOK, file /Users/jruderman/code/rust/src/llvm/lib/VMCore/Instructions.cpp, line 1062.

@nikomatsakis
Copy link
Contributor Author

The warning is, I believe, in error. I meant to file a separate bug on that but got distracted. I imagine the cause is the copy mode on insert().

@ghost ghost assigned nikomatsakis Aug 2, 2012
@Dretch
Copy link
Contributor

Dretch commented Aug 18, 2012

Replacing x in the argument list with &*x causes the testcase to compile and run.

@catamorphism
Copy link
Contributor

Compiles successfully for me with d2ad028

extern mod std;
use std::map::HashMap;
use std::map;

fn main() {
    let buggy_map :HashMap<uint, &uint> = HashMap::<uint, &uint>();
    let x = ~1;
    buggy_map.insert(42, x);
}

Closing.

RalfJung pushed a commit to RalfJung/rust that referenced this issue Aug 17, 2023
jaisnan pushed a commit to jaisnan/rust-dev that referenced this issue Jul 29, 2024
The current method for creating the modifies wrapper requires changing
the `ensures` clause to have `_renamed` variables which are unsafe
copies of the original function arguments. This causes issues with
regards to some possible tests as in rust-lang#3239.

This change removes the `_renamed` variables and instead simply changes
the modifies clauses within the replace to unsafely dereference the
pointer to modify the contents of it unsafely, condensing all instances
of unsafe Rust into a single location.

Resolves rust-lang#3239
Resolves rust-lang#3026
May affect rust-lang#3027. In my attempt to run this example with slight
modification to fit the current implementation, I got the error `CBMC
appears to have run out of memory. You may want to rerun your proof in
an environment with additional memory or use stubbing to reduce the size
of the code the verifier reasons about.` This suggests that the
compilation is working appropriately but the test case is just too large
for CBMC.

By submitting this pull request, I confirm that my contribution is made
under the terms of the Apache 2.0 and MIT licenses.

Co-authored-by: Matias Scharager <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-codegen Area: Code generation A-lifetimes Area: Lifetimes / regions I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️
Projects
None yet
Development

No branches or pull requests

4 participants