Skip to content

Fix upcall_vec_append self appending #573

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
wants to merge 4 commits into from
Closed

Fix upcall_vec_append self appending #573

wants to merge 4 commits into from

Conversation

msullivan
Copy link
Contributor

Fix bug #498.

@brson
Copy link
Contributor

brson commented Jun 25, 2011

This doesn't quite get there. If you modify the test case like so:

    let vec[int] a = [0];
    auto i = 20;
    auto expected_len = 1u;
    while (i > 0) {
        log_err vec::len(a);
        assert (vec::len(a) == expected_len);
        a += a;
        i -= 1;
        expected_len *= 2u;
    }

Then it's evident that the vector never grows. I suspect it's because src->fill == 0. I'd also like to see an identical test case for strings as well since off-by-1 errors are easy to miss here.

@brson
Copy link
Contributor

brson commented Jun 25, 2011

That is, if strings actually use this same code path then a string test would also be good. Not sure if that's the case or not.

@msullivan
Copy link
Contributor Author

The bug is that the if (src == dst) conditional assumes that the "regrow vector" path was taken in vec_grow. I'll push a fix in a minute.

Yeah, strings use the same code path.

@msullivan
Copy link
Contributor Author

OK, I think we should be good now.

@brson
Copy link
Contributor

brson commented Jun 27, 2011

Awesome, thanks!

@brson brson closed this Jun 27, 2011
antoyo added a commit to antoyo/rust that referenced this pull request Jan 13, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants