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

erroneous reinterpret only fails with --code-coverage=user #34865

Closed
maleadt opened this issue Feb 25, 2020 · 5 comments
Closed

erroneous reinterpret only fails with --code-coverage=user #34865

maleadt opened this issue Feb 25, 2020 · 5 comments
Labels
compiler:optimizer Optimization passes (mostly in base/compiler/ssair/) kind:bug Indicates an unexpected problem or unintended behavior

Comments

@maleadt
Copy link
Member

maleadt commented Feb 25, 2020

$ julia                      -e 'reinterpret(Nothing, nothing)'                               
                                               
$ julia --code-coverage=user -e 'reinterpret(Nothing, nothing)'                                                         
ERROR: bitcast: target type not a leaf primitive type
Stacktrace:
 [1] reinterpret(::Type{Nothing}, ::Nothing) at ./essentials.jl:413
 [2] top-level scope at none:1

Started behaving differently with 1.1, on 1.0 both fail. Arguably this use of reinterpret should be allowed, but the change in behavior based on code coverage had me stumped for a while.

@maleadt maleadt added kind:bug Indicates an unexpected problem or unintended behavior kind:regression Regression in behavior compared to a previous version labels Feb 25, 2020
@maleadt maleadt changed the title erroneous reinterpret works differently under --code-coverage=user erroneous reinterpret works with --code-coverage=user Feb 25, 2020
@maleadt maleadt changed the title erroneous reinterpret works with --code-coverage=user erroneous reinterpret only fails with --code-coverage=user Feb 25, 2020
@vtjnash
Copy link
Sponsor Member

vtjnash commented Feb 25, 2020

reinterpret(T, nothing) should fail consistently for all T, but we're in need of merging #34539

@vtjnash vtjnash added compiler:optimizer Optimization passes (mostly in base/compiler/ssair/) and removed kind:regression Regression in behavior compared to a previous version labels Feb 25, 2020
@vtjnash
Copy link
Sponsor Member

vtjnash commented Feb 25, 2020

Duplicate of #34482

@vtjnash vtjnash marked this as a duplicate of #34482 Feb 25, 2020
@vtjnash vtjnash closed this as completed Feb 25, 2020
@maleadt
Copy link
Member Author

maleadt commented Feb 25, 2020

reinterpret(T, nothing) should fail consistently for all T, but we're in need of merging #34539

What's the recommended way to create an instance of a singleton type then? This for implementing the GPU version of pointerset; calling T() seems fragile (user might have defined a constructor, and I just want an instance to make codegen happy and generate a ret void).

@vtjnash
Copy link
Sponsor Member

vtjnash commented Feb 25, 2020

unsafe_load could generate one (or its wrappers, such as Array{T,0}(undef)[]), though in general the system doesn't like to materialize undefined values from just their types

@maleadt
Copy link
Member Author

maleadt commented Feb 25, 2020

I was trying to mimick Base.pointerref which does handle that case:

julia> foo(ptr) = Base.pointerref(ptr,1,1)
foo (generic function with 1 method)

julia> code_llvm(foo, Tuple{Ptr{Nothing}})

;  @ REPL[4]:1 within `foo'
define void @julia_foo_17046(i64) {
top:
  ret void
}

maleadt added a commit to JuliaGPU/CUDAnative.jl that referenced this issue Feb 25, 2020
maleadt added a commit to JuliaGPU/CUDAnative.jl that referenced this issue Feb 25, 2020
maleadt added a commit to JuliaGPU/CUDAnative.jl that referenced this issue Mar 3, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compiler:optimizer Optimization passes (mostly in base/compiler/ssair/) kind:bug Indicates an unexpected problem or unintended behavior
Projects
None yet
Development

No branches or pull requests

2 participants