Skip to content

Commit f08cbfd

Browse files
danbevCommit Bot
authored andcommitted
Suppress cast-function-type in PersistentBase::SetWeak
This issue was seen in Node.js when compiling with GCC. It can also been see if building V8 using GCC and enabling -Wcast-function-type in BUILD.gn: "-Wcast-function-type", There are unit tests in V8 that produce this warning, for example test/cctest/test-global-handles.cc (formatted to fit the commit message width): g++ -MMD -MF obj/test/cctest/cctest_sources/test-global-handles.o.d ... In file included from ../../include/v8-inspector.h:14, from ../../src/execution/isolate.h:15, from ../../src/api/api.h:10, from ../../src/api/api-inl.h:8, from ../../test/cctest/test-global-handles.cc:28: ../../include/v8.h: In instantiation of ‘void v8::PersistentBase<T>::SetWeak( P*, typename v8::WeakCallbackInfo<P>::Callback, v8::WeakCallbackType) [with P = v8::Global<v8::Object>; T = v8::Object; typename v8::WeakCallbackInfo<P>::Callback = void (*)(const v8::WeakCallbackInfo<v8::Global<v8::Object> >&) ]’: ../../test/cctest/test-global-handles.cc:292:47: required from here ../../include/v8.h:10750:16: warning: cast between incompatible function types from ‘v8::WeakCallbackInfo<v8::Global<v8::Object> >::Callback’ {aka ‘void (*)(const v8::WeakCallbackInfo<v8::Global<v8::Object> >&)’} to ‘Callback’ {aka ‘void (*)(const v8::WeakCallbackInfo<void>&)’} [-Wcast-function-type] 10750 | reinterpret_cast<Callback>(callback), type); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ This commit suggests adding a pragma specifically for GCC to suppress this warning. Bug: v8:8735 Change-Id: I5dd2dccf215a7fd2f6dd14993368cc5cbb6c71e5 Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2080361 Reviewed-by: Jakob Kummerow <[email protected]> Reviewed-by: Ulan Degenbaev <[email protected]> Commit-Queue: Jakob Kummerow <[email protected]> Cr-Commit-Position: refs/heads/master@{#68320}
1 parent 08f0d06 commit f08cbfd

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

include/v8.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10811,8 +10811,15 @@ V8_INLINE void PersistentBase<T>::SetWeak(
1081110811
P* parameter, typename WeakCallbackInfo<P>::Callback callback,
1081210812
WeakCallbackType type) {
1081310813
typedef typename WeakCallbackInfo<void>::Callback Callback;
10814+
#if (__GNUC__ >= 8) && !defined(__clang__)
10815+
#pragma GCC diagnostic push
10816+
#pragma GCC diagnostic ignored "-Wcast-function-type"
10817+
#endif
1081410818
V8::MakeWeak(reinterpret_cast<internal::Address*>(this->val_), parameter,
1081510819
reinterpret_cast<Callback>(callback), type);
10820+
#if (__GNUC__ >= 8) && !defined(__clang__)
10821+
#pragma GCC diagnostic pop
10822+
#endif
1081610823
}
1081710824

1081810825
template <class T>

0 commit comments

Comments
 (0)