This is an archive of the discontinued LLVM Phabricator instance.

[libc++][test] Silence allocator conversion warnings
ClosedPublic

Authored by CaseyCarter on Jan 9 2023, 4:57 PM.

Details

Reviewers
philnik
ldionne
Group Reviewers
Restricted Project
Commits
rG886e92c1abf1: [libc++][test] Silence allocator conversion warnings
Summary

... by accepting std::size_t instead of int in allocate and deallocate functions.

Drive-by: To conform to the allocator requirements, the Allocator types in these tests need to have (1) converting constructors and (2) cross-specialization == that returns true at least for copies of the same allocator.

Diff Detail

Event Timeline

CaseyCarter created this revision.Jan 9 2023, 4:57 PM
Herald added a project: Restricted Project. · View Herald TranscriptJan 9 2023, 4:57 PM
CaseyCarter requested review of this revision.Jan 9 2023, 4:57 PM
Herald added a reviewer: Restricted Project. · View Herald TranscriptJan 9 2023, 4:57 PM
jloser added a subscriber: jloser.Jan 9 2023, 7:32 PM

Thanks for the fix! LGTM FWIW.

ldionne accepted this revision.Jan 10 2023, 10:08 AM
ldionne added a subscriber: ldionne.

CI issues seem unrelated. Just curious -- how did you catch that? Is there anything we can/should add to our implementation?

This revision is now accepted and ready to land.Jan 10 2023, 10:08 AM
This revision was landed with ongoing or failed builds.Jan 10 2023, 11:21 AM
This revision was automatically updated to reflect the committed changes.

CI issues seem unrelated. Just curious -- how did you catch that? Is there anything we can/should add to our implementation?

As you may be aware, MSVC doesn't have the "system header" notion that GCC/Clang do. Consequently we run testing with TONS of warnings enabled to ensure that our header code only emits warnings when the user has asked us to do something questionable. This is a pretty good example: Allocator's size type is size_t, so using this allocator with Standard Library containers results in lots of narrowing conversions from size_t to int. If the user asks for narrowing conversion warnings, they'll get them. The consequence is we have to police our tests pretty carefully to avoid warnings so we only see warnings from bad product code.

CI issues seem unrelated. Just curious -- how did you catch that? Is there anything we can/should add to our implementation?

As you may be aware, MSVC doesn't have the "system header" notion that GCC/Clang do. Consequently we run testing with TONS of warnings enabled to ensure that our header code only emits warnings when the user has asked us to do something questionable. This is a pretty good example: Allocator's size type is size_t, so using this allocator with Standard Library containers results in lots of narrowing conversions from size_t to int. If the user asks for narrowing conversion warnings, they'll get them. The consequence is we have to police our tests pretty carefully to avoid warnings so we only see warnings from bad product code.

Interesting! And I guess we don't enable this warning in our testing configuration. We have a block like this in params.py:

# These warnings should be enabled in order to support the MSVC
# team using the test suite; They enable the warnings below and
# expect the test suite to be clean.
'-Wsign-compare',
'-Wunused-variable',
'-Wunused-parameter',
'-Wunreachable-code',
'-Wno-unused-local-typedef',

Would it maybe make sense to add a new warning that would catch this?