Repository navigation
GCC warnings when compiling files in src #26733
Copy link
Copy link
Closed
Labels
c++Issues and PRs that require attention from people who are familiar with C++.Issues and PRs that require attention from people who are familiar with C++.help wantedIssues that need assistance from volunteers or PRs that need help to proceed.Issues that need assistance from volunteers or PRs that need help to proceed.
Description
I don't know if they are all fixable, but the first one is very annoying because it is emitted for (almost?) each C++ file:
In file included from ../src/node.h:63,
from ../src/api/callback.cc:1:
../deps/v8/include/v8.h: In instantiation of ‘void v8::PersistentBase<T>::SetWeak(P*, typename v8::WeakCallbackInfo<P>::Callback, v8::WeakCallbackType) [with P = node::BaseObject; T = v8::Object; typename v8::WeakCallbackInfo<P>::Callback = void (*)(const v8::WeakCallbackInfo<node::BaseObject>&)]’:
../src/base_object-inl.h:104:42: required from here
../deps/v8/include/v8.h:9585:16: warning: cast between incompatible function types from ‘v8::WeakCallbackInfo<node::BaseObject>::Callback’ {aka ‘void (*)(const v8::WeakCallbackInfo<node::BaseObject>&)’} to ‘Callback’ {aka ‘void (*)(const v8::WeakCallbackInfo<void>&)’} [-Wcast-function-type]
reinterpret_cast<Callback>(callback), type);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from ../src/node_buffer.cc:29:
../src/string_search.h: In function ‘size_t node::stringsearch::SearchString(node::stringsearch::Vector<const Char>, node::stringsearch::Vector<const Char>, size_t) [with Char = short unsigned int]’:
../src/string_search.h:113:30: warning: ‘search’ may be used uninitialized in this function [-Wmaybe-uninitialized]
return (this->*strategy_)(subject, index);
~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~
../src/string_search.h: In function ‘size_t node::stringsearch::SearchString(node::stringsearch::Vector<const Char>, node::stringsearch::Vector<const Char>, size_t) [with Char = unsigned char]’:
../src/string_search.h:113:30: warning: ‘search’ may be used uninitialized in this function [-Wmaybe-uninitialized]
return (this->*strategy_)(subject, index);
~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
c++Issues and PRs that require attention from people who are familiar with C++.Issues and PRs that require attention from people who are familiar with C++.help wantedIssues that need assistance from volunteers or PRs that need help to proceed.Issues that need assistance from volunteers or PRs that need help to proceed.
Activity
refack commentedon Mar 18, 2019
https://github.com/proxy/gist.github.com/refack/1cc202e9b507d63d108d5ba55293e540 with 167 warnings from MSVC
src,win: fix usage of deprecated v8::Object::Set
src: use explicit casts to silence conversion warnings
1 remaining item
cjihrig commentedon May 2, 2019
@targos is this still an issue?
targos commentedon May 2, 2019
@cjihrig Yes, I can still reproduce all warnings from the OP with GCC 8 and 9.
bmsdave commentedon Oct 18, 2019
@targos
I would like to try to solve this problem. I'll try it next week.
bmsdave commentedon Oct 28, 2019
@targos hi. Can you describe the steps to reproduce these notifications?
targos commentedon Oct 28, 2019
@bmsdave Hello. I can reproduce the warnings on my system (Fedora 30, GCC 9.2.1) with:
I removed the other two warnings from the OP because I can't reproduce them anymore.
gireeshpunathil commentedon Jan 7, 2020
just wondering between this and #18983 , are we talking about the same thing?
targos commentedon Jan 7, 2020
It doesn't look like the same thing.
lundibundi commentedon Jan 8, 2020
Not sure we can do anything about the rest of them:
The
search_stringones are caused by uninitialized arrays (they are initialized when needed and not upon object creation) inSearchStringBasewhich can be initialized (i.e.= {0}) with 1-2% performance impact or suppressed with something like#pragma GCC diagnostic ignored "-Wmaybe-uninitialized"(this should also work for clang). Not sure if this is needed though pragma ignore would probably be fine.The
Wcast-function-typeis from thebase_object-inl.hspecifically thev8::PersistentBase::SetWeakcall which usesreinterpret_castfromWeakCallbackInfo<Type>toWeakCallbackInfo<void>which is okay for C++ and is just fine in there IIUC. I don't think this is possible to fix on our end. I'd consider this one aswontfixhowever annoying it is, unfortunately.src: fix -Wmaybe-uninitialized compiler warning
src: fix -Wmaybe-uninitialized compiler warning
src: fix -Wmaybe-uninitialized compiler warning
src: fix -Wmaybe-uninitialized compiler warning