Skip to content

Conversation

@bangbangsheshotmedown
Copy link

@bangbangsheshotmedown bangbangsheshotmedown commented Oct 28, 2024

I came up with all that casting by trial&error, but something tells me that there should be a much simpler solution..

@alexrp
Copy link
Member

alexrp commented Jan 29, 2025

test
+- test-modules
   +- test-std
      +- run test std-wasm32-wasi.0.1...0.2.2-musl-generic-Debug
         +- zig test Debug wasm32-wasi 1 errors
/home/ci/actions-runner5/_work/zig/zig/lib/std/fmt.zig:668:90: error: @ptrCast increases pointer alignment
/home/ci/actions-runner5/_work/zig/zig/lib/std/fmt.zig:668:99: note: '*const anyopaque' has alignment '1'
/home/ci/actions-runner5/_work/zig/zig/lib/std/fmt.zig:668:90: note: '*const u16' has alignment '2'
/home/ci/actions-runner5/_work/zig/zig/lib/std/fmt.zig:668:90: note: use @alignCast to assert pointer alignment

@rohlem
Copy link
Contributor

rohlem commented Jan 29, 2025

With #22505 merged, the new implementation should just use .sentinel(), which takes care of all the casting. Something like (untested):

if (info.sentinel()) |s| {
  const index = std.mem.indexOfSentinel(info.child, s, value[0..]);
  return formatBuf(value[0..index], options, writer);
}

@bangbangsheshotmedown

This comment was marked as abuse.

@Vexu
Copy link
Member

Vexu commented Jan 30, 2025

You do not need to build Zig to test changes to the standard library, you just need to point --zig-lib-dir at your modified lib directory.

https://github.com/ziglang/zig/wiki/Contributing#directly-testing-the-standard-library-with-zig-test

@ifreund ifreund closed this Aug 26, 2025
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.

5 participants