commit 7d882b5945badae6f14190c03afdd3000d0df4a2
parent 1c0edca8161fc5625a4035a9df087376494cc1de
Author: Jan de Mooij <jdemooij@mozilla.com>
Date: Thu, 20 Nov 2025 12:46:01 +0000
Bug 2001062 - Fix 'std::is_pod is deprecated' warnings in js/src after C++20 update. r=iain,rhunt
Drop-in replacement for `std::is_pod` is `std::is_standard_layout && std::is_trivial`,
but most code doesn't need both checks. Furthermore, `std::is_trivial` will be deprecated
in C++26. This patch uses `std::is_trivially_copyable` instead.
Differential Revision: https://phabricator.services.mozilla.com/D273200
Diffstat:
2 files changed, 5 insertions(+), 4 deletions(-)
diff --git a/js/src/irregexp/util/VectorShim.h b/js/src/irregexp/util/VectorShim.h
@@ -21,9 +21,9 @@ namespace internal {
template <typename T>
T* NewArray(size_t size) {
- static_assert(std::is_pod<T>::value, "");
+ static_assert(std::is_trivially_copyable_v<T>);
js::AutoEnterOOMUnsafeRegion oomUnsafe;
- T* result = static_cast<T*>(js_malloc(size * sizeof(T)));
+ T* result = js_pod_malloc<T>(size);
if (!result) {
oomUnsafe.crash("Irregexp NewArray");
}
@@ -32,6 +32,7 @@ T* NewArray(size_t size) {
template <typename T>
void DeleteArray(T* array) {
+ static_assert(std::is_trivially_destructible_v<T>);
js_free(array);
}
diff --git a/js/src/wasm/AsmJS.cpp b/js/src/wasm/AsmJS.cpp
@@ -204,8 +204,8 @@ struct LitValPOD {
}
};
-static_assert(std::is_pod_v<LitValPOD>,
- "must be POD to be simply serialized/deserialized");
+static_assert(std::is_trivially_copyable_v<LitValPOD>,
+ "must be trivially copyable for serialization/deserialization");
// An AsmJSGlobal represents a JS global variable in the asm.js module function.
class AsmJSGlobal {