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
GCC warning with -Wconversion and undefined behavior for unknown_array_type #1066
warning: the result of the conversion is unspecified because ‘-1’ is outside the range of type ‘napi_typedarray_type’ [-Wconversion]
911 | static const napi_typedarray_type unknown_array_type = static_cast<napi_typedarray_type>(-1);
|
I don't think this is really an issue, but it would be nice to get rid of the warning.
@zbjornson would you like to submit a suggested PR? I'd have to think more about whether changing the value would be a problem or not but I assume there are other ways to suppress the warking as well.
Sure. I'll take a look at better solutions, but #pragma GCC diagnostics ignored "-Wconversion" would minimally work. The C++ spec defines this enum to have an implicit size of int, which has at least 16 bits, and the enum has 11 members currently, which is why I said it's probably not an issue. However, since C++17 this line is actually undefined behavior, not just an unspecified value.
node-addon-api could maybe have its own enum that has the same values as napi_typedarray_type plus an unknown type. I think that would be unobtrusive.
This issue is stale because it has been open many days with no activity. It will be closed soon unless the stale label is removed or a comment is made.
changed the title [-]GCC warning with -Wconversion for unknown_array_type[/-][+]GCC warning with -Wconversion and undefined behavior for unknown_array_type[/+]on Jan 5, 2022
This issue is stale because it has been open many days with no activity. It will be closed soon unless the stale label is removed or a comment is made.
This issue is stale because it has been open many days with no activity. It will be closed soon unless the stale label is removed or a comment is made.
Activity
mhdawson commentedon Sep 8, 2021
@zbjornson would you like to submit a suggested PR? I'd have to think more about whether changing the value would be a problem or not but I assume there are other ways to suppress the warking as well.
zbjornson commentedon Sep 8, 2021
Sure. I'll take a look at better solutions, but
#pragma GCC diagnostics ignored "-Wconversion"would minimally work. The C++ spec defines this enum to have an implicit size ofint, which has at least 16 bits, and the enum has 11 members currently, which is why I said it's probably not an issue. However, since C++17 this line is actually undefined behavior, not just an unspecified value.node-addon-api could maybe have its own enum that has the same values as
napi_typedarray_typeplus anunknowntype. I think that would be unobtrusive.github-actions commentedon Dec 8, 2021
This issue is stale because it has been open many days with no activity. It will be closed soon unless the stale label is removed or a comment is made.
[-]GCC warning with -Wconversion for unknown_array_type[/-][+]GCC warning with -Wconversion and undefined behavior for unknown_array_type[/+]github-actions commentedon Apr 11, 2022
This issue is stale because it has been open many days with no activity. It will be closed soon unless the stale label is removed or a comment is made.
mhdawson commentedon Apr 12, 2022
@zbjornson were you still planning to submit a PR on this?
github-actions commentedon Jul 12, 2022
This issue is stale because it has been open many days with no activity. It will be closed soon unless the stale label is removed or a comment is made.
NickNaso commentedon Nov 3, 2022
I'm closing the issue because it has been solved with PR #1209