Closed
Bug 1763741
Opened 2 years ago
Closed 2 years ago
IntCoordTyped / CoordTyped take too much space on Windows.
Categories
(Core :: Graphics, defect)
Core
Graphics
Tracking
()
RESOLVED
FIXED
101 Branch
Tracking | Status | |
---|---|---|
firefox101 | --- | fixed |
People
(Reporter: emilio, Assigned: emilio)
References
Details
Attachments
(2 files, 1 obsolete file)
This patch makes our builds fail on Windows pretty hard:
diff --git a/gfx/2d/Coord.h b/gfx/2d/Coord.h
index fd2ab15f88b5e..07cd88141e5d0 100644
--- a/gfx/2d/Coord.h
+++ b/gfx/2d/Coord.h
@@ -96,8 +96,14 @@ struct IntCoordTyped
using Super = BaseCoord<Rep, IntCoordTyped<units, Rep>>;
- constexpr IntCoordTyped() : Super() {}
- constexpr MOZ_IMPLICIT IntCoordTyped(Rep aValue) : Super(aValue) {}
+ constexpr IntCoordTyped() : Super() {
+ static_assert(sizeof(IntCoordTyped) == sizeof(Rep),
+ "Would be unfortunate otherwise!");
+ }
+ constexpr MOZ_IMPLICIT IntCoordTyped(Rep aValue) : Super(aValue) {
+ static_assert(sizeof(IntCoordTyped) == sizeof(Rep),
+ "Would be unfortunate otherwise!");
+ }
};
template <class units, class F>
@@ -116,10 +122,19 @@ struct CoordTyped : public BaseCoord<F, CoordTyped<units, F>>,
using Super = BaseCoord<F, CoordTyped<units, F>>;
- constexpr CoordTyped() : Super() {}
- constexpr MOZ_IMPLICIT CoordTyped(F aValue) : Super(aValue) {}
+ constexpr CoordTyped() : Super() {
+ static_assert(sizeof(CoordTyped) == sizeof(F),
+ "Would be unfortunate otherwise!");
+ }
+ constexpr MOZ_IMPLICIT CoordTyped(F aValue) : Super(aValue) {
+ static_assert(sizeof(CoordTyped) == sizeof(F),
+ "Would be unfortunate otherwise!");
+ }
explicit constexpr CoordTyped(const IntCoordTyped<units>& aCoord)
- : Super(F(aCoord.value)) {}
+ : Super(F(aCoord.value)) {
+ static_assert(sizeof(CoordTyped) == sizeof(F),
+ "Would be unfortunate otherwise!");
+ }
void Round() { this->value = floor(this->value + 0.5); }
void Truncate() { this->value = int32_t(this->value); }
This was caught by Hiro while doing some Rust bindings stuff.
Assignee | ||
Comment 1•2 years ago
|
||
Assignee | ||
Updated•2 years ago
|
Attachment #9271399 -
Attachment mime type: text/x-c++src → text/plain
Assignee | ||
Comment 2•2 years ago
|
||
This program builds on Linux/macOS/Android, but the static assert in main() fails on Windows: https://godbolt.org/z/veaK994j3
Attachment #9271399 -
Attachment is obsolete: true
Assignee | ||
Comment 3•2 years ago
|
||
Assignee | ||
Comment 4•2 years ago
|
||
This is an attribute that could be useful elsewhere so seems worth
putting in mfbt.
Updated•2 years ago
|
Assignee: nobody → emilio
Status: NEW → ASSIGNED
Pushed by ealvarez@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/235ffcec5f53 Make gfx types take the right amount of space in MSVC. r=jrmuizel,glandium
Comment 6•2 years ago
|
||
bugherder |
Status: ASSIGNED → RESOLVED
Closed: 2 years ago
status-firefox101:
--- → fixed
Resolution: --- → FIXED
Target Milestone: --- → 101 Branch
You need to log in
before you can comment on or make changes to this bug.
Description
•