Zig Version
0.17.0-dev.836+e357134f0
Steps to Reproduce, Observed Behavior, and Expected Behavior
zig build-obj repro.zig -fllvm
// repro.zigconstPORTA:*u32=@ptrFromInt(0x1000);constPORTB:*u32=@ptrFromInt(0x2000);exportfnread_reg(reg:*u32)u32{returnswitch(reg){PORTA=>PORTA.*,PORTB=>PORTB.*,else=>unreachable,};}
The result is the same regardless of the pointer value coming from @ptrFromInt() or from the address of a variable.
Background
I found it while upgrading MicroZig to Zig master. We switch on a pointer here. -fllvm is needed because it compiles fine on the self-hosted backend.
The repro is minimal while keeping to the general structure you'd see in MicroZig. MMIO pointers are usually volatile, but I have removed that here since it still reproduces the issue.
### Zig Version
0.17.0-dev.836+e357134f0
### Steps to Reproduce, Observed Behavior, and Expected Behavior
```
zig build-obj repro.zig -fllvm
```
```zig
// repro.zig
const PORTA: *u32 = @ptrFromInt(0x1000);
const PORTB: *u32 = @ptrFromInt(0x2000);
export fn read_reg(reg: *u32) u32 {
return switch (reg) {
PORTA => PORTA.*,
PORTB => PORTB.*,
else => unreachable,
};
}
```
The result is the same regardless of the pointer value coming from `@ptrFromInt()` or from the address of a variable.
### Background
I found it while upgrading MicroZig to Zig master. We switch on a pointer [here](https://github.com/ZigEmbeddedGroup/microzig/blob/5aee49b86130b06c8b136ee5ba0687564861b25e/port/wch/ch32v/src/hals/gpio.zig#L121). `-fllvm` is needed because it compiles fine on the self-hosted backend.
The repro is minimal while keeping to the general structure you'd see in MicroZig. MMIO pointers are usually volatile, but I have removed that here since it still reproduces the issue.