Skip to content

make enum bounds declaration required for any use with simple enum functions #34

@vilchanskyio-work

Description

@vilchanskyio-work

Hi, thanks for wring this library.

Unfortunately, it suffers from the same issue as magic_enum, trying to static_cast non-existing enum values, albeit it doesn't spam 120+ warnings, but only 3:

<redacted>/simple_enum/simple_enum.hpp:339:89:   in 'constexpr' expansion of 'simple_enum::v0_9::detail::prepare_enum_meta_info<QCanBusDevice::CanBusError, 0, 10>()'
<redacted>/simple_enum/simple_enum.hpp:303:50: warning: the result of the conversion is unspecified because '(1 + 7)' is outside the range of type 'QCanBusDevice::CanBusError' [-Wconversion]
  303 |     (..., cont_pass<static_cast<enum_type>(first + utype(indices))>(meta[indices + 1], enum_beg));
      |                                            ~~~~~~^~~~~~~~~~~~~~~~
<redacted>/simple_enum/simple_enum.hpp:303:50: warning: the result of the conversion is unspecified because '(1 + 8)' is outside the range of type 'QCanBusDevice::CanBusError' [-Wconversion]
<redacted>/simple_enum/simple_enum.hpp:303:50: warning: the result of the conversion is unspecified because '(1 + 9)' is outside the range of type 'QCanBusDevice::CanBusError' [-Wconversion]

For reference QCanBusDevice::CanBusError is defined as:

    enum CanBusError {
        NoError,
        ReadError,
        WriteError,
        ConnectionError,
        ConfigurationError,
        UnknownError,
        OperationError,
        TimeoutError
    };

Is it possible to address this?

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions