I’ve got a really simple C++ 20 struct with a constexpr ctor. Compiles and runs fine with GCC recent versions, but not MSVC 2022 with latest patches. Is the MSVC compiler incorrect, or have I missed something?
#include <stdint.h>
/// Info from GPS, assembled from multiple NMEA sentences into coherent summary
/// WGS84, NED...
struct GPSinfo_T {
/// Status bit masks
enum StatusFlagsT {
NFG = 0,
time_OK = 1, ///< time and date populated
navigation_OK = 2, ///< RMC field 14 Positioning status is S=Safe (not C=Caution, U=Unsafe, or V=Positioning status not valid)
HPR_OK = 4, ///< ???
};
uint8_t statusBitmap; ///< StatusFlagsT above defines bits
bool TimeIsOK() const { return (statusBitmap&time_OK) != 0; };
bool NavigatingOK() const { return (statusBitmap&navigation_OK) != 0; }; // RMC field 14 == 'S' Safe
bool HPRisOK() const { return HPR_QF=='4' || HPR_QF=='5'; }; // ToDo GPS: use bit in statusBitmap, now set...
/// What constellations were used in this fix (from GNS sentence)?
/// One character status for each of these constellations:
/// - First character is for GPS.
/// - Second character is for GLONASS.
/// - Third character is Galileo.
/// - Fourth character is for BeiDou.
/// - Fifth character is for QZSS.
/// - Sixth is terminating 0.
/// We need 'A' autonomous, especially not 'E' estimated or 'N' none...
char fixSources[6];
/// 'Quality of Fix' from HPR sentence
char HPR_QF;
/// 'Position Status' from RMC
char RMC_PS;
uint32_t satellitesUsed;
double hdop;
/// Time
uint32_t UTC_time_hundredths; // hundredths of seconds since UTC midnight
uint32_t dateDDMMYY; // in ddmmyy, not decoded into anything useful like Unix time_t
/// Position angles in degrees, North and East are positive.
double latitude, longitude;
double altitude; // meters
/// Track (from RMC, calculated as difference between fixes)
double track_TrueHeading, track_MPS;
/// Heading and Pitch from HPR sentence (calculated using 2 antennas)
double HPR_heading, HPR_pitch;
constexpr GPSinfo_T():
statusBitmap(NFG), fixSources("NNNNN"), HPR_QF(' '), RMC_PS(' '), satellitesUsed(0), hdop(9999.0),
UTC_time_hundredths(0), dateDDMMYY(0),
latitude(0.0), longitude(0.0), altitude(0.0),
track_TrueHeading(0.0), track_MPS(0.0), HPR_heading(0.0), HPR_pitch(0.0)
{};
};