Skip to content

Conversation

@Stevengre
Copy link
Contributor

No description provided.

@Stevengre Stevengre self-assigned this Nov 7, 2025
@Stevengre Stevengre marked this pull request as ready for review November 7, 2025 05:25
@Stevengre Stevengre force-pushed the jh/align-transparent-place branch 2 times, most recently from 24c0f88 to 0f140fa Compare November 10, 2025 08:27
Base automatically changed from jh/zero-sized to master November 10, 2025 08:29
@Stevengre Stevengre force-pushed the jh/align-transparent-place branch 2 times, most recently from 070066e to 195d6f6 Compare November 10, 2025 08:41
Copy link
Collaborator

@dkcumming dkcumming left a comment

Choose a reason for hiding this comment

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

@Stevengre I think this is all good, I will approve but I also think @jberthold should take a loook

Copy link
Member

@jberthold jberthold left a comment

Choose a reason for hiding this comment

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

LGTM overall.
Please clarify why the orBool is used. The missing ) is not too important unless you re-run CI anyway.

Conversion is especially possible for the case of _Slices_ (of dynamic length) and _Arrays_ (of static length),
which have the same representation `Value::Range`.

When the cast crosses transparent wrappers (newtypes that just forward field `0` e.g. `struct Wrapper<T>(T)`, the pointer's
Copy link
Member

Choose a reason for hiding this comment

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

(nit-pick)

Suggested change
When the cast crosses transparent wrappers (newtypes that just forward field `0` e.g. `struct Wrapper<T>(T)`, the pointer's
When the cast crosses transparent wrappers (newtypes that just forward field `0` e.g. `struct Wrapper<T>(T)`), the pointer's

Comment on lines +66 to +67
rule #typesCompatible(SRC, OTHER) => true
requires #zeroSizedType(SRC) orBool #zeroSizedType(OTHER)
Copy link
Member

Choose a reason for hiding this comment

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

A bit puzzled by the orBool here... I would accept it immediately with andBool (one zero-sized thing is as good as another) but what happens if we cast a pointer to non-zero-sized to a zero-sized one and back, should that be allowed? Or which side is not allowed? (zero to non-zero I would guess)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm investigating this with a new test, but it encounters other ndbranches.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It needs a cast from pointer to integer. here: #812

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I provided pointer-cast-zst.rs to cover this scenario: it casts a *const Wrapper to *const () (ZST) and back, then asserts the roundtrip preserves the value. Since this test passes, the semantics currently allow non‑zero → zero → non‑zero pointer casts, so we shoud use this orBool to allow this situation.

Comment on lines +29 to +55
│ (111 steps)
├─ 7
│ #expect ( thunk ( #applyBinOp ( binOpEq , thunk ( #applyBinOp ( binOpBitAnd , th
│ function: main
┃ (1 step)
┣━━┓
┃ │
┃ ├─ 8
┃ │ AssertError ( assertMessageMisalignedPointerDereference ( ... required: operandC
┃ │ function: main
┃ │
┃ │ (1 step)
┃ └─ 10 (stuck, leaf)
┃ #ProgramError ( AssertError ( assertMessageMisalignedPointerDereference ( ... re
┃ function: main
┗━━┓
├─ 9
│ #execBlockIdx ( basicBlockIdx ( 7 ) ) ~> .K
│ function: main
│ (17 steps)
└─ 11 (stuck, leaf)
#setLocalValue ( place ( ... local: local ( 1 ) , projection: .ProjectionElems )
function: main
Copy link
Member

Choose a reason for hiding this comment

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

FYI This now hits a non-deterministic branch on what looks like a pointer alignment check .

Copy link
Collaborator

Choose a reason for hiding this comment

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

@jberthold I saw this last night in a previous proof, it comes when the pointer cast is thunked, and then the pointer is branches. I am worried it is happening because it needs to get the address but I haven't looked with details yet. If it needs the address I am not sure what we do

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think I solved it before in the big pr. Could I introduce an issue for this and solve it later in another pr?

Copy link
Member

Choose a reason for hiding this comment

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

Yes, we can solve this one later, it should not block this PR

@Stevengre Stevengre force-pushed the jh/align-transparent-place branch from 973bd17 to d55c2e7 Compare November 13, 2025 06:11
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.

4 participants