Skip to content

GCC warning with -Wconversion and undefined behavior for unknown_array_type #1066

@zbjornson

Description

@zbjornson

This line:

static const napi_typedarray_type unknown_array_type = static_cast<napi_typedarray_type>(-1);

causes a warning with -Wconversion enabled:

 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.

(https://wiki.sei.cmu.edu/confluence/display/cplusplus/INT50-CPP.+Do+not+cast+to+an+out-of-range+enumeration+value)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions