You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Atomic intrinsics pass an element view's address as the value (D27 materialization skipped) #1287
Found rewriting `examples/ephemerality-and-lowering` under #1150 ruling 4.
`Atomic[i32].store(v, order)` / `fetch_add` are lowered as intrinsics (`src/MirLower.w:10359`, `ATOMIC_STORE`). When the argument is a positional element view (`xs[i]` or `xs.get(i)`, exact type `&i32` per D27 / §3.8), the intrinsic path does not materialize the `Copy` pointee under the owned demand of the `T` parameter: on a global `Atomic` the stored value is the element's address (consecutive elements differ by 4), and on a local `Atomic` the store is a no-op. A plain or generic function parameter (`fn take(v: i32)`, `fn take_gen[T](v: T)`) receives the value correctly, so the defect is in the intrinsic argument lowering, not in the view itself.
Repro (installed `with v0.15.2.1-g478b26481`):
```
use std.sync
var a: Atomic[i32] = Atomic.new(0)
fn main:
var order = Vec.new()
order.push(1)
order.push(2)
order.push(3)
a.store(order[2], .SeqCst)
print(f"a={a.load(.SeqCst)}") // expected 3; prints e.g. 39534616
a.store(order.get(1), .SeqCst)
print(f"a={a.load(.SeqCst)}") // expected 2; prints 39534612
let b: Atomic[i32] = Atomic.new(0)
b.store(order[2], .SeqCst)
print(f"b={b.load(.SeqCst)}") // expected 3; prints 0
```
Expected: both print the element value. Spec: §3.8 / D27 (an owned demand materializes a `Copy` pointee), §14.17.1.
Workaround in the example: `let v: i32 = order[2]` then `store(v, ...)` (remove when fixed).
Activity
examples: rewritten to the current spec (D55 ruling 4) + examples-tes…
examples: restore the spec spellings #1308 parked behind now-fixed co…