Skip to content

BoundedArray.fromSlice() returns error type 'u8' does not support indexing due to @memcpy #15694

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

Closed
Deins opened this issue May 13, 2023 · 1 comment
Labels
bug Observed behavior contradicts documented or intended behavior

Comments

@Deins
Copy link

Deins commented May 13, 2023

Zig Version

0.11.0-dev.3107+6547d2331

Steps to Reproduce and Observed Behavior

// when global variable or struct member, worked as local variable, but might be that it got optimized maybe out
var string : std.BoundedArray(u8, 32) = std.BoundedArray(u8, 32).fromSlice("hello world") catch unreachable;

snippet in godbolt
returns error:

bounded_array.zig:76:13: error: type 'u8' does not support indexing
            @memcpy(list.slice(), m);
            ^~~~~~~~~~~~~~~~~~~~~~~~
W:\dev\zig\tools\zig-master\lib\std\bounded_array.zig:76:13: note: operand must be an array, slice, tuple, or vector
src\server\main.zig:8:72: note: called from here
    map : std.BoundedArray(u8, 32) = std.BoundedArray(u8, 32).fromSlice("default 9x12") catch unreachable,
                                     ~~~~~~~~~~~~~~~~~~~

I think it worked few versions back, so possibly regression.

Expected Behavior

Just works

@Deins Deins added the bug Observed behavior contradicts documented or intended behavior label May 13, 2023
@jacobly0
Copy link
Member

Duplicate of #15633

@Vexu Vexu closed this as completed May 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Observed behavior contradicts documented or intended behavior
Projects
None yet
Development

No branches or pull requests

3 participants