-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
Be a little more flexible about Span constructors. #26701
Merged
bzbarsky-apple
merged 1 commit into
project-chip:master
from
bzbarsky-apple:better-span-constructors
May 23, 2023
Merged
Be a little more flexible about Span constructors. #26701
bzbarsky-apple
merged 1 commit into
project-chip:master
from
bzbarsky-apple:better-span-constructors
May 23, 2023
Conversation
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
pullapprove
bot
requested review from
amitnj,
andy31415,
anush-apple,
arkq,
carol-apple,
cecille,
chrisdecenzo,
chshu,
chulspro,
cliffamzn,
Damian-Nordic,
dhrishi,
electrocucaracha,
emargolis,
franck-apple,
gjc13,
harsha-rajendran,
hawk248,
jelderton,
jepenven-silabs,
jmartinez-silabs,
jmeg-sfy,
joonhaengHeo,
jtung-apple,
kcoppock,
kkasperczyk-no,
ksperling-apple and
lazarkov
May 19, 2023 19:13
pullapprove
bot
requested review from
mrjerryjohns,
msandstedt,
mspang,
nivi-apple,
saurabhst,
selissia,
sharadb-amazon,
tcarmelveilleux,
tecimovic,
turon,
vijs,
vivien-apple,
woody-apple,
xylophone21,
younghak-hwang and
yunhanw-google
May 19, 2023 19:13
PR #26701: Size comparison from f55fa96 to 476d041 Increases (22 builds for bl702, cc32xx, esp32, k32w, linux, psoc6)
Decreases (4 builds for bl702, efr32, nrfconnect)
Full report (42 builds for bl602, bl702, cc32xx, cyw30739, efr32, esp32, k32w, linux, mbed, nrfconnect, psoc6, qpg)
|
bzbarsky-apple
force-pushed
the
better-span-constructors
branch
from
May 19, 2023 20:53
476d041
to
504a947
Compare
PR #26701: Size comparison from 149b756 to 504a947 Increases (26 builds for bl702, cc32xx, k32w, linux, psoc6, telink)
Decreases (10 builds for bl602, bl702, efr32, k32w, nrfconnect, telink)
Full report (57 builds for bl602, bl702, cc32xx, cyw30739, efr32, esp32, k32w, linux, mbed, nrfconnect, psoc6, qpg, telink)
|
Before this change, this code: struct X { int member; }; struct Y : public X { }; Y object; Span<X> span(&Y, 1); would not compile, because we had std::is_same checks on the types (X and Y in this case). But this code is in fact safe as long as sizeof(Y) == sizeof(X), so we don't get confused about our object boundaries. This change replaces the std::is_same checks with sizeof() checks. But that leads to some situations being ambiguous, because the "can this pointer actually work for us?" check happens after overload resolution, so we explicitly do the std::is_convertible checks alongside sizeof to make sure that the pointer passed to our Span constructor will work.
bzbarsky-apple
force-pushed
the
better-span-constructors
branch
from
May 20, 2023 03:36
504a947
to
0cd5f9d
Compare
PR #26701: Size comparison from bfa0580 to 0cd5f9d Increases (28 builds for bl602, bl702, cc32xx, linux, psoc6, telink)
Decreases (7 builds for bl702, efr32, esp32, telink)
Full report (57 builds for bl602, bl702, cc32xx, cyw30739, efr32, esp32, k32w, linux, mbed, nrfconnect, psoc6, qpg, telink)
|
jmartinez-silabs
approved these changes
May 22, 2023
p0fi
approved these changes
May 22, 2023
arkq
approved these changes
May 23, 2023
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Before this change, this code:
would not compile, because we had std::is_same checks on the types (X and Y in this case). But this code is in fact safe as long as sizeof(Y) == sizeof(X), so we don't get confused about our object boundaries.
This change replaces the std::is_same checks with sizeof() checks. But that leads to some situations being ambiguous, because the "can this pointer actually work for us?" check happens after overload resolution, so we explicitly do the std::is_convertible checks alongside sizeof to make sure that the pointer passed to our Span constructor will work.