You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Failures in CI across platforms after nogc env update #1573
../../napi-inl.h:5011:63: error: parameter ‘env’ set but not used [-Werror=unused-but-set-parameter]
inline void ObjectWrap<T>::FinalizeCallback(node_api_nogc_env env,
It looks like env is unused with the default defines, should just need to adjust the parameter definition, looking at it.
It's not as simple because of the constexpr checks: we only need to use env if the base class defines certain methods.
The test fails with:
In file included from ../../napi.h:3257,
from ../addon_data.cc:3:
../../napi-inl.h: In instantiation of ‘static void Napi::ObjectWrap<T>::FinalizeCallback(node_api_nogc_env, void*, void*) [with T = Addon::VerboseIndicator; node_api_nogc_env = napi_env__*]’:
... and this is because Addon::VerboseIndicator does not have a Finalize. Since there's no VerboseIndicator::Finalize, the ObjectWrap::FinalizeCallback doesn't use the env parameter.
Looking at the previous implementation: the ObjectWrap base class defines an empty Finalize() to call with env:
Should I do something similar...? Seems odd to need to do this just to get rid of the warning... but I could imagine some projects using the same warnings-as-error configuration for this unused-but-set-parameter.
Ah, okay ... I had to use the constexpr approach because the delete instance; either happens immediately (if constexpr for "has extended finalizer" condition fails) or gets delayed to the ObjectWrap::PostFinalizeCallback if there is a delayed finalizer.
Doing something similar to the old approach (ie. defining a no-op, non-basic Finalize) would not work, since the delete instance would then be delayed.
Activity
mhdawson commentedon Sep 4, 2024
@KevinEady is that something you have some cycles to look at ?
mhdawson commentedon Sep 4, 2024
It looks like
envis unused with the default defines, should just need to adjust the parameter definition, looking at it.KevinEady commentedon Sep 4, 2024
It's not as simple because of the
constexprchecks: we only need to useenvif the base class defines certain methods.The test fails with:
... and this is because
Addon::VerboseIndicatordoes not have aFinalize. Since there's noVerboseIndicator::Finalize, theObjectWrap::FinalizeCallbackdoesn't use theenvparameter.Looking at the previous implementation: the
ObjectWrapbase class defines an emptyFinalize()to call withenv:node-addon-api/napi-inl.h
Lines 4924 to 4932 in bf49519
node-addon-api/napi-inl.h
Lines 4837 to 4838 in bf49519
Should I do something similar...? Seems odd to need to do this just to get rid of the warning... but I could imagine some projects using the same warnings-as-error configuration for this
unused-but-set-parameter.KevinEady commentedon Sep 4, 2024
Ah, okay ... I had to use the
constexprapproach because thedelete instance;either happens immediately (if constexpr for "has extended finalizer" condition fails) or gets delayed to the ObjectWrap::PostFinalizeCallback if there is a delayed finalizer.Doing something similar to the old approach (ie. defining a no-op, non-basic
Finalize) would not work, since thedelete instancewould then be delayed.Soooo not sure exactly how to address.
NickNaso commentedon Sep 4, 2024
Could be the following code a possible solution:
mhdawson commentedon Sep 4, 2024
@NickNaso I was thinking about something similar to what you suggested except:
EDIT: but looking at the two I think I prefer the one that @NickNaso suggested.
mhdawson commentedon Sep 4, 2024
But looking at it I don't think that will work because of the constexpr as the use of env is not just based on the define.