Mark operator c2_cntr64_t as constexpr
Upcoming compiler update emits warning:
hardware/google/av/codec2/tests/C2_test.cpp:142:19: error: static_assert expression is not an integral constant expression
static_assert(c2_cntr32_t(1) == c2_cntr32_t(c2_cntr64_t(0x100000001ul)), "1 == 1");
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
hardware/google/av/codec2/tests/C2_test.cpp:142:49: note: non-constexpr function 'operator c2_cntr_t<unsigned int, void>' cannot be used in a constant expression
static_assert(c2_cntr32_t(1) == c2_cntr32_t(c2_cntr64_t(0x100000001ul)), "1 == 1");
^
hardware/google/av/codec2/include/C2.h:292:12: note: declared here
inline operator c2_cntr_t<U>() {
^
Mark the method constexpr to fix the error.
Test: m checkbuild
Bug: 126457671
Change-Id: I97d1e420f818f8ad928d25ec242cf71ce2c33054
diff --git a/codec2/include/C2.h b/codec2/include/C2.h
index 8a55f8d..ef3466d 100644
--- a/codec2/include/C2.h
+++ b/codec2/include/C2.h
@@ -289,7 +289,7 @@
* Convert to a smaller counter type. This is always safe.
*/
template<typename U, typename E=typename std::enable_if<(sizeof(U) < sizeof(T))>::type>
- inline operator c2_cntr_t<U>() {
+ inline constexpr operator c2_cntr_t<U>() {
return c2_cntr_t<U>(mValue);
}