gMethods: const not constexpr
A C-style cast from a function pointer to void* requires a C++
reinterpret_cast, which is forbidden in a constexpr initializer. New
versions of Clang diagnose this:
frameworks/base/core/jni/android_media_MediaMetricsJNI.cpp:225:34: error: constexpr variable 'gMethods' must be initialized by a constant expression
225 | static constexpr JNINativeMethod gMethods[] = {
| ^ ~
226 | {"native_submit_bytebuffer", "(Ljava/nio/ByteBuffer;I)I",
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
227 | (void *)android_media_MediaMetrics_submit_bytebuffer},
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
228 | };
| ~
frameworks/base/core/jni/android_media_MediaMetricsJNI.cpp:227:13: note: cast that performs the conversions of a reinterpret_cast is not allowed in a constant expression
227 | (void *)android_media_MediaMetrics_submit_bytebuffer},
| ^
See https://github.com/llvm/llvm-project/pull/150557.
Use a `const` variable instead of `constexpr`, matching the pattern in
other C++ source files in this directory. (There are many files that
declare a gMethods variable.)
Bug: none
Test: presubmit
Flag: EXEMPT bugfix
Change-Id: I5f0feb94d7fd531eafb3c9fc2df1cf05ac588f85
Loading
Please register or sign in to comment