From 826de6beff81ec2b8e5229f574654b587f2c6050 Mon Sep 17 00:00:00 2001 From: wmayer Date: Mon, 27 Jul 2020 16:00:47 +0200 Subject: [PATCH] LGTM: [skip ci]: Ambiguously signed bit-field member Until C++11 bit fields with integral types should have explicit signedness only. It is implementation specific whether an -typed bit field is signed, so there could be unexpected sign extension or overflow. This means that if depending on the compiler int32_t is not explicitly defined as signed the UnitSignature structure may not work as expected. Since C++14 this has changed and an int of a bit-field is always signed: https://stackoverflow.com/questions/33723631/signed-bit-field-in-c14 --- src/Base/Unit.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/Base/Unit.h b/src/Base/Unit.h index eb539a13a4..d0ea6818c8 100644 --- a/src/Base/Unit.h +++ b/src/Base/Unit.h @@ -43,6 +43,9 @@ namespace Base { #define UnitSignatureLuminousIntensityBits 4 #define UnitSignatureAngleBits 4 +// Hint: +// https://en.cppreference.com/w/cpp/language/bit_field +// https://stackoverflow.com/questions/33723631/signed-bit-field-in-c14 struct UnitSignature{ int32_t Length:UnitSignatureLengthBits; int32_t Mass:UnitSignatureMassBits;