This is an archive of the discontinued LLVM Phabricator instance.

Fix sizeof of boolean vector
ClosedPublic

Authored by Fznamznon on Jan 25 2023, 8:04 AM.

Details

Summary

Ensure it is at least 8 bits.

Fixes #59801

Diff Detail

Event Timeline

Fznamznon created this revision.Jan 25 2023, 8:04 AM
Herald added a project: Restricted Project. · View Herald TranscriptJan 25 2023, 8:04 AM
Fznamznon requested review of this revision.Jan 25 2023, 8:04 AM
Herald added a project: Restricted Project. · View Herald TranscriptJan 25 2023, 8:04 AM
Herald added a subscriber: cfe-commits. · View Herald Transcript
tbaeder added inline comments.
clang/test/SemaCXX/vector-bool.cpp
95

Should be 4 instead of 8, shouldn't it?

Fznamznon added inline comments.Jan 25 2023, 8:07 AM
clang/test/SemaCXX/vector-bool.cpp
95

This is not four bools.

erichkeane added inline comments.Jan 25 2023, 8:07 AM
clang/test/SemaCXX/vector-bool.cpp
95

Can you add another couple of 'oddball' sizes and make sure they work out right? I THINK the alignment logic gets it right, but I'd like tests to confirm.

Fznamznon added inline comments.Jan 25 2023, 8:09 AM
clang/test/SemaCXX/vector-bool.cpp
95

Yes, will fix in a moment.

Fznamznon marked an inline comment as not done.Jan 25 2023, 8:09 AM
Fznamznon updated this revision to Diff 492125.Jan 25 2023, 8:23 AM

Adjust the test

Fznamznon added inline comments.Jan 25 2023, 8:24 AM
clang/test/SemaCXX/vector-bool.cpp
95

Okay, done.

erichkeane added inline comments.Jan 25 2023, 8:25 AM
clang/test/SemaCXX/vector-bool.cpp
97

How about 33? Does it grow appropriately with alignment?

Fznamznon updated this revision to Diff 492151.Jan 25 2023, 9:23 AM

Add a case with vector of length 33

Fznamznon added inline comments.Jan 25 2023, 9:25 AM
clang/test/SemaCXX/vector-bool.cpp
97

Its sizeof evaluates to 8. Looking at the code in ASTContext that seems to be appropriate result since 8 is a next power of 2 after 4.

Just a couple more I'm concerned about after thinking about it, otherwise this looks about right.

clang/test/SemaCXX/vector-bool.cpp
97

Yep, that makes sense to me! Can you do 1 more group for me?

65, 129, 150, 195, 257?

Fznamznon updated this revision to Diff 492362.Jan 26 2023, 2:00 AM

Add more sizes to test

clang/test/SemaCXX/vector-bool.cpp
97

Sure, done. Seems to be working in the same way.

erichkeane accepted this revision.Jan 26 2023, 5:53 AM

Ok, thank you! This looks right to me :)

This revision is now accepted and ready to land.Jan 26 2023, 5:53 AM
This revision was landed with ongoing or failed builds.Jan 26 2023, 7:58 AM
This revision was automatically updated to reflect the committed changes.