-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
Miscompilation of invalid conditionals when both branches yield the same value #29306
Comments
Here's a reduced example which shows this is a weird transformation of the conditional (not related to generators per se): julia> function foo(x)
if x > 0
x
else
missing
end
end
foo (generic function with 1 method)
julia> foo(missing) # Should produce an error
missing
julia> @code_typed foo(missing)
CodeInfo(
2 1 ─ goto #3 if not $(QuoteNode(missing)) │
3 2 ─ return x │
5 3 ─ return Main.missing │
) => Missing I'm really not sure what that |
A further reduced example, showing that this is also independent of julia> function foo()
if "Move right along, nothing to see here"
10
else
10
end
end
foo (generic function with 2 methods)
julia> foo()
10
julia> @code_typed foo()
CodeInfo(
2 1 ─ goto #3 if not "Move right along, nothing to see here" │
3 2 ─ return 10 │
5 3 ─ return 10 │
) => Int64 |
Ok, this is an error somewhere in codegen - running julia with |
More weirdness - reasonable looking code is shown by julia> function foo()
if "asdf"
10
else
10
end
end
foo (generic function with 1 method)
julia> @code_llvm foo()
; Function foo
; Location: REPL[1]:2
; Function Attrs: sspstrong
define i64 @julia_foo_789307557() #0 {
top:
call void @jl_type_error_rt(i8* inttoptr (i64 94190438521104 to i8*), i8* inttoptr (i64 94190439063072 to i8*), %jl_value_t addrspace(10)* addrspacecast (%jl_value_t* inttoptr (i64 140252862974832 to %jl_value_t*) to %jl_value_t addrspace(10)*), %jl_value_t addrspace(12)* addrspacecast (%jl_value_t* inttoptr (i64 140252904070960 to %jl_value_t*) to %jl_value_t addrspace(12)*))
unreachable
}
julia> foo()
10
julia> @code_llvm foo()
; Function foo
; Location: REPL[1]:2
; Function Attrs: sspstrong
define i64 @julia_foo_789307561() #0 {
top:
ret i64 10
} |
The definition of
e
should give the same error as forc
andd
, or at leastb
!The text was updated successfully, but these errors were encountered: