summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Lioncash2022-10-18 15:37:37 -0400
committerGravatar Lioncash2022-10-18 16:06:50 -0400
commit6e1c6297a3f8fcd243ec6b31d3832d84c7df474c (patch)
tree4b8de4393bafeb6a8a8c61f66fbf6a1940630e06
parentfixed_point: Mark copy/move assignment operators and constructors as constexpr (diff)
downloadyuzu-6e1c6297a3f8fcd243ec6b31d3832d84c7df474c.tar.gz
yuzu-6e1c6297a3f8fcd243ec6b31d3832d84c7df474c.tar.xz
yuzu-6e1c6297a3f8fcd243ec6b31d3832d84c7df474c.zip
fixed_point: Mark default constructor as constexpr
Ensures that a fixed-point value is always initialized This likely also fixes several cases of uninitialized values being operated on, since we have multiple areas in the codebase where the default constructor is being used like: Common::FixedPoint<50, 14> current_sample{}; and is then followed up with an arithmetic operation like += or something else, which operates directly on FixedPoint's internal data member, which would previously be uninitialized.
-rw-r--r--src/common/fixed_point.h4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/common/fixed_point.h b/src/common/fixed_point.h
index 5aafa273b..f899b0d54 100644
--- a/src/common/fixed_point.h
+++ b/src/common/fixed_point.h
@@ -267,7 +267,7 @@ public:
267 static constexpr base_type one = base_type(1) << fractional_bits; 267 static constexpr base_type one = base_type(1) << fractional_bits;
268 268
269public: // constructors 269public: // constructors
270 FixedPoint() = default; 270 constexpr FixedPoint() = default;
271 271
272 constexpr FixedPoint(const FixedPoint&) = default; 272 constexpr FixedPoint(const FixedPoint&) = default;
273 constexpr FixedPoint& operator=(const FixedPoint&) = default; 273 constexpr FixedPoint& operator=(const FixedPoint&) = default;
@@ -463,7 +463,7 @@ public:
463 } 463 }
464 464
465public: 465public:
466 base_type data_; 466 base_type data_{};
467}; 467};
468 468
469// if we have the same fractional portion, but differing integer portions, we trivially upgrade the 469// if we have the same fractional portion, but differing integer portions, we trivially upgrade the