Skip to content

Commit

Permalink
Default initialize fixed point Eigen types.
Browse files Browse the repository at this point in the history
In certain cases, tensors are filled with default values of the type. But, for these fixed point types, these values were uninitialized. Thus, we would have uninitialized memory access bugs, some of which were caught by MSAN.

PiperOrigin-RevId: 344101137
Change-Id: I14555fda74dca3b5f1582da9008901937e3f14e2
  • Loading branch information
mihaimaruseac authored and serach24 committed Jun 4, 2021
1 parent 4af3ff6 commit 13deaba
Showing 1 changed file with 5 additions and 5 deletions.
Expand Up @@ -49,7 +49,7 @@ struct scalar_product_traits<QInt32, double> {
// the compiler from silently type cast the mantissa into a bigger or a smaller
// representation.
struct QInt8 {
QInt8() {}
QInt8() : value(0) {}
QInt8(const int8_t v) : value(v) {}
QInt8(const QInt32 v);

Expand All @@ -59,7 +59,7 @@ struct QInt8 {
};

struct QUInt8 {
QUInt8() {}
QUInt8() : value(0) {}
QUInt8(const uint8_t v) : value(v) {}
QUInt8(const QInt32 v);

Expand All @@ -69,7 +69,7 @@ struct QUInt8 {
};

struct QInt16 {
QInt16() {}
QInt16() : value(0) {}
QInt16(const int16_t v) : value(v) {}
QInt16(const QInt32 v);
operator int() const { return static_cast<int>(value); }
Expand All @@ -78,7 +78,7 @@ struct QInt16 {
};

struct QUInt16 {
QUInt16() {}
QUInt16() : value(0) {}
QUInt16(const uint16_t v) : value(v) {}
QUInt16(const QInt32 v);
operator int() const { return static_cast<int>(value); }
Expand All @@ -87,7 +87,7 @@ struct QUInt16 {
};

struct QInt32 {
QInt32() {}
QInt32() : value(0) {}
QInt32(const int8_t v) : value(v) {}
QInt32(const int32_t v) : value(v) {}
QInt32(const uint32_t v) : value(static_cast<int32_t>(v)) {}
Expand Down

0 comments on commit 13deaba

Please sign in to comment.