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

pointerset causes compilation failures (even in non-reachable code branches) #3240

Closed
carlobaldassi opened this issue May 29, 2013 · 1 comment

Comments

@carlobaldassi
Copy link
Member

Example:

function h{T}(x::Array{T})
  if isbits(T)
    unsafe_store!(pointer(x), 1)
  else         
    x[1] = 1
  end
  return x
end

the fact that unsafe_store! is not defined for non-bits types should not prevent compilation, but:

julia> h([3,3,3])
3-element Int64 Array:
 1
 3
 3

julia> h({3,3,3})
ERROR: error compiling h: pointerset: invalid pointer type

On a related note, I've seen that (at least in some cases) even though the information required to choose a branch is available at compile time (e.g. the isbits(T) should be trivially known from T), the code is not optimized away. I wonder if there's anything which could be done about this.

@JeffBezanson
Copy link
Sponsor Member

Yes, more can definitely be done with constant branches.

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

No branches or pull requests

2 participants