Skip to content

Fix compilation with GCC 9

Andreas Cord-Landwehr requested to merge work/fix-gcc9-compile into master

Fixes build error with GCC 9 of the following

| /opt/yocto/kde/nanbield/build-visionfive2/tmp/work/x86_64-linux/ki18n-native/6.0.0/ki18n-6.0.0/src/localedata/timezonedata.cpp:15:34: error: non-constant condition for static assertion
|    15 | static_assert(isSortedLookupTable(country_timezone_map));
|       |               ~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
| /opt/yocto/kde/nanbield/build-visionfive2/tmp/work/x86_64-linux/ki18n-native/6.0.0/ki18n-6.0.0/src/localedata/timezonedata.cpp:15:34: error: ‘constexpr bool isSortedLookupTable(const MapEntry (&)[N]) [with MapEntry = MapEntry<short unsigned int>; long unsigned int N = 214]’ called in a constant expression
| In file included from /opt/yocto/kde/nanbield/build-visionfive2/tmp/work/x86_64-linux/ki18n-native/6.0.0/ki18n-6.0.0/src/localedata/timezonedata_p.h:10,
|                  from /opt/yocto/kde/nanbield/build-visionfive2/tmp/work/x86_64-linux/ki18n-native/6.0.0/ki18n-6.0.0/src/localedata/timezonedata.cpp:7:
| /opt/yocto/kde/nanbield/build-visionfive2/tmp/work/x86_64-linux/ki18n-native/6.0.0/ki18n-6.0.0/src/localedata/mapentry_p.h:42:23: note: ‘constexpr bool isSortedLookupTable(const MapEntry (&)[N]) [with MapEntry = MapEntry<short unsigned int>; long unsigned int N = 214]’ is not usable as a ‘constexpr’ function because:
|    42 | inline constexpr bool isSortedLookupTable(const MapEntry (&map)[N])
|       |                       ^~~~~~~~~~~~~~~~~~~
| /opt/yocto/kde/nanbield/build-visionfive2/tmp/work/x86_64-linux/ki18n-native/6.0.0/ki18n-6.0.0/src/localedata/mapentry_p.h:45:26: error: call to non-‘constexpr’ function ‘bool std::is_sorted(_FIter, _FIter) [with _FIter = const MapEntry<short unsigned int>*]’
|    45 |     return std::is_sorted(std::begin(map), std::end(map));
|       |            ~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

I was only able to check that this fixes the build with GCC-9, not confirm that it builds with GCC-10 due to missing GCC versions on my side.

Edited by Andreas Cord-Landwehr

Merge request reports