mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-27 14:52:16 +00:00
Bug 1757565 - Explicitly cast from size_t to uint32_t in nsTStringLengthStorage. r=xpcom-reviewers,mccr8
I was looking at what all fails with -Werror=shorten-64-to-32 and this showed up prominently. Differential Revision: https://phabricator.services.mozilla.com/D139940
This commit is contained in:
parent
76ca55d0b9
commit
2f82844d6b
@ -80,12 +80,12 @@ class nsTStringLengthStorage {
|
||||
// Implicit conversion and assignment from `size_t` which assert that the
|
||||
// value is in-range.
|
||||
MOZ_IMPLICIT constexpr nsTStringLengthStorage(size_t aLength)
|
||||
: mLength(aLength) {
|
||||
: mLength(static_cast<uint32_t>(aLength)) {
|
||||
MOZ_RELEASE_ASSERT(aLength <= kMax, "string is too large");
|
||||
}
|
||||
constexpr nsTStringLengthStorage& operator=(size_t aLength) {
|
||||
MOZ_RELEASE_ASSERT(aLength <= kMax, "string is too large");
|
||||
mLength = aLength;
|
||||
mLength = static_cast<uint32_t>(aLength);
|
||||
return *this;
|
||||
}
|
||||
MOZ_IMPLICIT constexpr operator size_t() const { return mLength; }
|
||||
|
Loading…
Reference in New Issue
Block a user