Skip to content
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

RMC incorrectly reports an assertion failure on a two-dimensional vector #435

Closed
zhassan-aws opened this issue Aug 17, 2021 · 2 comments · Fixed by #402
Closed

RMC incorrectly reports an assertion failure on a two-dimensional vector #435

zhassan-aws opened this issue Aug 17, 2021 · 2 comments · Fixed by #402
Labels
[C] Bug This is a bug. Something isn't working.

Comments

@zhassan-aws
Copy link
Contributor

I tried this code:

fn main() {
    let a: Vec<Vec<i32>> = vec![vec![0; 2]; 1];
    assert!(a.len() == 1);
}

using the following command line invocation:

rmc test.rs

with RMC version: main-154-2021-08-06

I expected the assertion to pass, but it didn't:

[main.assertion.1] line 3 assertion failed: a.len() == 1: FAILURE

If I compile the test and run it, the assertion is not hit:

$ rustc test.rs 
$ ./test 
$ 

Also, if I modify the first line in the function to

    let a: Vec<Vec<i32>> = vec![vec![0; 2]];

i.e. leave out the length for the outer vector, the assertion passes.

@zhassan-aws zhassan-aws added the [C] Bug This is a bug. Something isn't working. label Aug 17, 2021
@chinmaydd
Copy link

chinmaydd commented Aug 18, 2021

The call hierarchy on using the vec! macro for initialization of a Vec with a value looks like:

extend_with uses the SetLenOnDrop optimization as described in #191. Since rmc does not currently handle drop behavior, the length of the Vec does not hold the correct value after initialization. This behavior should be fixed by a combination #402 and #336.

@avanhatt avanhatt mentioned this issue Aug 18, 2021
4 tasks
@avanhatt
Copy link
Contributor

Added as a unit test in #402

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[C] Bug This is a bug. Something isn't working.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants