This is an archive of the discontinued LLVM Phabricator instance.

[libc++][test] fix C4267 warning in bitset.members\to_ulong.pass.cpp
ClosedPublic

Authored by fsb4000 on Aug 14 2022, 3:37 AM.

Details

Summary

warning C4267: 'initializing': conversion from 'size_t' to 'unsigned long', possible loss of data

Diff Detail

Event Timeline

fsb4000 created this revision.Aug 14 2022, 3:37 AM
Herald added a project: Restricted Project. · View Herald TranscriptAug 14 2022, 3:37 AM
fsb4000 requested review of this revision.Aug 14 2022, 3:37 AM
Herald added a reviewer: Restricted Project. · View Herald TranscriptAug 14 2022, 3:37 AM

What does it warn on when you don't explicitly cast if to unsigned long?

I mean why are you casting it to unsigned long? AFAICT std::bitset() should take an unsigned long long, so it shouldn't be a narrowing conversion when calling it with std::size_t.

fsb4000 updated this revision to Diff 452522.Aug 14 2022, 7:45 AM

Thanks. Yes, you are right. It fixes the warning too.

philnik accepted this revision.Aug 14 2022, 8:06 AM
This revision is now accepted and ready to land.Aug 14 2022, 8:06 AM
This revision was landed with ongoing or failed builds.Aug 14 2022, 8:26 AM
This revision was automatically updated to reflect the committed changes.