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

Fix error message for direct pointer access #541

Closed
dsrbecky opened this issue Jun 8, 2017 · 6 comments
Closed

Fix error message for direct pointer access #541

dsrbecky opened this issue Jun 8, 2017 · 6 comments

Comments

@dsrbecky
Copy link
Contributor

dsrbecky commented Jun 8, 2017

ptr[1] = .... fails with "type u64 not valid slicing pointer"
We generally work around the bug by slicing the pointer first.

@ben-clayton
Copy link
Contributor

Please can I have a bit more code context? I'm not confident I know the exact issue.

@dsrbecky
Copy link
Contributor Author

dsrbecky commented Jun 8, 2017

cmd void glGenBuffers(GLsizei count, BufferId* buffers) {
  if count < 0 { glErrorInvalidValue() }
  b := buffers[0:count]
  ctx := GetContext()
  for i in (0 .. count) {
    id := as!BufferId(?)
    assert(id != 0)
    ctx.Objects.Shared.GeneratedNames.Buffers[id] = true
    b[i] = id // Why not just buffers[i] = id?
  }
}

@ben-clayton
Copy link
Contributor

I see.

We generally work around the bug by slicing the pointer first.

Actually this is a conscious design decision as nearly all (if not all?) parameter arrays have a known upper bound, and this forces you to specify it. Without the slice step, it's far easier to accidentally buffer overrun / underrun. By removing raw pointer offsets I caught quite a few issues with this in early development of GAPID.

Does the extra slice step really hurt? @AWoloszyn, any thoughts on this?

@dsrbecky
Copy link
Contributor Author

dsrbecky commented Jun 9, 2017

It does not hurt that much, but I find it odd - at the very least the error message is odd.

@ben-clayton
Copy link
Contributor

at the very least the error message is odd.

Agreed. I'm more than happy to fix that.

@ben-clayton ben-clayton removed their assignment Jun 14, 2017
@AWoloszyn
Copy link
Contributor

I do prefer the explicitly sized slices for things.
The extra slice is a bit cumbersome, but most of the time I have not been annoyed with it.

@dsrbecky dsrbecky changed the title It would be nice to be able to write to pointers Fix error message for direct pointer access Nov 8, 2017
ben-clayton added a commit to ben-clayton/gapid that referenced this issue Jan 15, 2018
As discussed in google#541, we were intentionally forcing the developer to go
via a slice, but TexParameter!T would be horrible to implement with this
constraint in place as T can be a static array or slice.

Fixes google#541
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants