Skip to content

Conversation

@Rua
Copy link
Contributor

@Rua Rua commented Nov 26, 2025

This is more idiomatic, and is also necessary for supporting strict(er) provenance in the future.

@Rua Rua force-pushed the null_ptr branch 2 times, most recently from 88f376c to 4ae5c83 Compare November 26, 2025 17:36
@Rua
Copy link
Contributor Author

Rua commented Nov 26, 2025

The testsuite is crashing with a stack overflow. Since all this PR does is replace a cast with a function call, is that particular test nesting calls so deeply that a few extra is making it overrun?

@ahomescu
Copy link
Contributor

This has happened before in the lua test, I made immunant/c2rust-testsuite#37 to compile it in release mode so it doesn't use as much stack.

Copy link
Contributor

@kkysen kkysen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Thanks for this; it's very nice to have a provenance correct translation, and also miri won't complain about this stuff anymore if we're looking for other more serious issues.

pub static mut scope: *mut Scope = &{
let mut init = Scope {
next: 0 as *const Scope as *mut Scope,
next: ::core::ptr::null::<Scope>() as *mut Scope,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We probably want to fix how we're generating this so that we just use null_mut directly, but this is fine for now, and still technically correct.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh wait, I see why it's happening now. Nevermind. Nice fix.

@kkysen kkysen merged commit 2310426 into immunant:master Dec 7, 2025
5 checks passed
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.

Use std::ptr::null_mut::<T>() instead of 0 as *mut T

3 participants