-
-
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
For structs with all isbits or isbitsunion fields, allow them to be s… #32448
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5852,9 +5852,9 @@ let | |
b3 = B23367[b][1] # copy b via array assignment | ||
addr(@nospecialize x) = ccall(:jl_value_ptr, Ptr{Cvoid}, (Any,), x) | ||
@test addr(b) == addr(b) | ||
@test addr(b) == addr(b2) | ||
@test addr(b) == addr(b3) | ||
@test addr(b2) == addr(b3) | ||
# @test addr(b) == addr(b2) | ||
# @test addr(b) == addr(b3) | ||
# @test addr(b2) == addr(b3) | ||
|
||
@test b === b2 === b3 === b | ||
@test egal(b, b2) && egal(b2, b3) && egal(b3, b) | ||
|
@@ -5863,7 +5863,7 @@ let | |
@test b.x === Int8(91) | ||
@test b.z === Int8(23) | ||
@test b.y === A23367((Int8(1), Int8(2), Int8(3), Int8(4), Int8(5), Int8(6), Int8(7))) | ||
@test sizeof(b) == sizeof(Int) * 3 | ||
@test sizeof(b) == 12 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So I think this is more correct now? The change is via the call to |
||
@test A23367(Int8(1)).x === Int8(1) | ||
@test A23367(Int8(0)).x === Int8(0) | ||
@test A23367(Int16(1)).x === Int16(1) | ||
|
@@ -5891,6 +5891,25 @@ for U in boxedunions | |
end | ||
end | ||
|
||
struct UnionFieldInlineStruct | ||
x::Int64 | ||
y::Union{Float64, Missing} | ||
end | ||
|
||
@test sizeof(Vector{UnionFieldInlineStruct}(undef, 2)) == sizeof(UnionFieldInlineStruct) * 2 | ||
|
||
let x = UnionFieldInlineStruct(1, 3.14) | ||
AInlineUnion = [x for i = 1:10] | ||
@test sizeof(AInlineUnion) == sizeof(UnionFieldInlineStruct) * 10 | ||
BInlineUnion = Vector{UnionFieldInlineStruct}(undef, 10) | ||
copyto!(BInlineUnion, AInlineUnion) | ||
@test AInlineUnion == BInlineUnion | ||
@test BInlineUnion[end] == x | ||
CInlineUnion = vcat(AInlineUnion, BInlineUnion) | ||
@test sizeof(CInlineUnion) == sizeof(UnionFieldInlineStruct) * 20 | ||
@test CInlineUnion[end] == x | ||
end | ||
|
||
# issue 31583 | ||
a31583 = "a" | ||
f31583() = a31583 === "a" | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@vtjnash, these tests are failing on this branch; is that expected? I'm not sure why the Ref
b2
case would be affected by anything I've changed, but I think I understand that forb3
, because it's an array, when we store it in an array (inline now), then extract it back again, it's technically a differentjl_value_ptr
, but still the same bits.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, so it looks like in the Ref case, the alignment of
B23367
is now different, which is used bydatatype_pointerfree
, to determine how tounsafe_convert
to a Ptr. Again, it seems like we're more correct now by saying thatB23367
is indeeddatatype_pointerfree
. I'm not sure how much people really run into this kind of thing because doing ccall w/ structs w/ Union fields probably isn't very common.