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

Prevent pointer -> int casts in constexprs #18315

Merged
merged 1 commit into from
Oct 28, 2014

Conversation

arielb1
Copy link
Contributor

@arielb1 arielb1 commented Oct 25, 2014

These cause issues, as addresses aren't fixed at compile-time.

Fixes #18294

These cause issues, as addresses aren't fixed at compile-time.

Fixes rust-lang#18294
alexcrichton added a commit to alexcrichton/rust that referenced this pull request Oct 27, 2014
@bors bors merged commit 81b7e62 into rust-lang:master Oct 28, 2014
@pnkfelix
Copy link
Member

if these are disallowed ... then i guess the only reason for allowing int->ptr casts is for encoding null? Is that accurate?

I ask because int->ptr casts are clearly part of the recipe that leads to #13973

@eddyb
Copy link
Member

eddyb commented Apr 19, 2015

@pnkfelix being able to dereference a raw pointer in a constant is the bug there. What semantics could it possibyt have, that don't involve tracking such values specially and limit the operations that can be performed on resulting lvalues and references?

@pnkfelix
Copy link
Member

@eddyb but doesn't taking the address of the dereference effectively cancel out the dereference? Am I being naive about this?

Update: and yes, I basically am talking about tracking more meta-data in the const-evaluator. I opened an RFC issue about this last night, see rust-lang/rfcs#1071

@eddyb
Copy link
Member

eddyb commented Apr 19, 2015

Remember that taking the address of a dereference always produces a safe reference, so need to track that reference and disallow any use that may lead to a compile-time dereference, e.g. 1 + *&*(1337 as *const u8) should not compile (with or without *&).

lnicola pushed a commit to lnicola/rust that referenced this pull request Oct 17, 2024
Bump version of scip crate

Follow up to sourcegraph/scip#284

Manually verified that SCIP generation works OK for rust-analyzer itself.

cc `@RalfJung`
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.

constants are not constant due to ptr->int casts
5 participants