-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Proposal: do not allow ++
on many-ptrs
#19435
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
Labels
Milestone
Comments
mlugg
added a commit
to mlugg/zig
that referenced
this issue
Mar 26, 2024
This commit also performs some refactors to `TypedValue.print` in preparation for improved comptime pointer access logic. Once that logic exists, `TypedValue.print` can use Sema to access pointers for more helpful printing. This commit also implements proposal ziglang#19435, because the existing logic there relied on some blatantly incorrect code in `Value.sliceLen`. Resolves: ziglang#19435
Merged
mlugg
added a commit
to mlugg/zig
that referenced
this issue
Mar 26, 2024
This commit also performs some refactors to `TypedValue.print` in preparation for improved comptime pointer access logic. Once that logic exists, `TypedValue.print` can use Sema to access pointers for more helpful printing. This commit also implements proposal ziglang#19435, because the existing logic there relied on some blatantly incorrect code in `Value.sliceLen`. Resolves: ziglang#19435
Rexicon226
pushed a commit
to Rexicon226/zig
that referenced
this issue
Mar 29, 2024
This commit also performs some refactors to `TypedValue.print` in preparation for improved comptime pointer access logic. Once that logic exists, `TypedValue.print` can use Sema to access pointers for more helpful printing. This commit also implements proposal ziglang#19435, because the existing logic there relied on some blatantly incorrect code in `Value.sliceLen`. Resolves: ziglang#19435
Rexicon226
pushed a commit
to Rexicon226/zig
that referenced
this issue
Mar 29, 2024
This commit also performs some refactors to `TypedValue.print` in preparation for improved comptime pointer access logic. Once that logic exists, `TypedValue.print` can use Sema to access pointers for more helpful printing. This commit also implements proposal ziglang#19435, because the existing logic there relied on some blatantly incorrect code in `Value.sliceLen`. Resolves: ziglang#19435
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
In status quo Zig, you can use
++
with many-ptr operands. The intention (as indicated by comments on the implementation) is that these many-ptrs should be sentinel-terminated, and that the compiler would essentially dostd.mem.span
for you - in practice, the compiler currently does something much stranger to do with its internal representation of pointers.Both the actual and intended behavior here seem incorrect. The process of effectively converting a many-ptr to a slice (by virtue of assigning it a length) is not one the compiler should perform implicitly: the user should make this intent clear by performing this conversion in userland, such as with
std.mem.span
, as is the case for quite literally every other construct in Zig.I therefore propose that this feature be removed, and that instead the operands to
++
must have a known length (i.e. they must be arrays, vectors, tuples, or slices). The migration path for any userland code relying on this feature (if any exists, that is; I highly doubt it does) will simply be to add calls tostd.mem.span
where needed.The text was updated successfully, but these errors were encountered: