Skip to content
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

Unexpected error: out of bounds slice #4093

Closed
artob opened this issue Jan 6, 2020 · 2 comments
Closed

Unexpected error: out of bounds slice #4093

artob opened this issue Jan 6, 2020 · 2 comments
Labels
bug Observed behavior contradicts documented or intended behavior stage1 The process of building from source via WebAssembly and the C backend.
Milestone

Comments

@artob
Copy link

artob commented Jan 6, 2020

const std = @import("std");
const testing = std.testing;

const ZlibStreamHeader = packed struct {
  cmf: u8,
  flg: u8,
};

const zlibHeader = ZlibStreamHeader{
  .cmf = 0x78,
  .flg = 0x01,
};

test "reproduce 'error: out of bounds slice'" {
  testing.expect(@sizeOf(@TypeOf(zlibHeader)) == 2);

  const ptr1 = @ptrCast([*]const u8, &zlibHeader)[0..@sizeOf(@TypeOf(zlibHeader))];

  //const ptr2 = @ptrCast([*]const u8, &zlibHeader)[0..2]; // same
}

Screen Shot 2020-01-06 at 23 48 18

This is with HEAD (2e53425). Possibly related issues: #1150, #1292

@daurnimator
Copy link
Contributor

There's also some related discussion in #1738 (comment)

@andrewrk andrewrk added this to the 0.6.0 milestone Jan 7, 2020
@andrewrk andrewrk added bug Observed behavior contradicts documented or intended behavior stage1 The process of building from source via WebAssembly and the C backend. labels Jan 7, 2020
@andrewrk
Copy link
Member

andrewrk commented Jan 7, 2020

I'm making a note to add coverage for this test case when doing #3133.

@andrewrk andrewrk modified the milestones: 0.6.0, 0.7.0 Feb 10, 2020
@andrewrk andrewrk modified the milestones: 0.7.0, 0.8.0 Aug 13, 2020
@andrewrk andrewrk modified the milestones: 0.8.0, 0.9.0 Nov 6, 2020
@andrewrk andrewrk modified the milestones: 0.9.0, 0.10.0 May 19, 2021
andrewrk added a commit that referenced this issue Dec 18, 2022
andrewrk added a commit that referenced this issue Dec 18, 2022
andrewrk added a commit that referenced this issue Dec 18, 2022
@andrewrk andrewrk modified the milestones: 0.12.0, 0.11.0 Dec 19, 2022
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 stage1 The process of building from source via WebAssembly and the C backend.
Projects
None yet
Development

No branches or pull requests

3 participants