Neargye / semver

Semantic Versioning for modern C++
MIT License
300 stars 32 forks source link

constexpr function never produces a constant expression #33

Closed flagarde closed 2 years ago

flagarde commented 2 years ago

Hello,

Thanks for your nice library. Trying to compile it with clang 6.0.1 results on compiler error : constexpr function never produces a constant expression

/home/runner/work/YAODAQ/YAODAQ/build/_deps/semver-src/include/semver.hpp:513:26: error: constexpr function never produces a constant expression [-Winvalid-constexpr]
    auto is_logical_or = [&parser]() constexpr noexcept -> bool { return parser.current_token.type == range_token_type::logical_or; };
                         ^
/home/runner/work/YAODAQ/YAODAQ/build/_deps/semver-src/include/semver.hpp:513:74: note: read of non-constexpr variable 'parser' is not allowed in a constant expression
    auto is_logical_or = [&parser]() constexpr noexcept -> bool { return parser.current_token.type == range_token_type::logical_or; };
                                                                         ^
/home/runner/work/YAODAQ/YAODAQ/build/_deps/semver-src/include/semver.hpp:511:18: note: declared here
    range_parser parser{str_};
                 ^
/home/runner/work/YAODAQ/YAODAQ/build/_deps/semver-src/include/semver.hpp:515:24: error: constexpr function never produces a constant expression [-Winvalid-constexpr]
    auto is_operator = [&parser]() constexpr noexcept -> bool { return parser.current_token.type == range_token_type::range_operator; };
                       ^
/home/runner/work/YAODAQ/YAODAQ/build/_deps/semver-src/include/semver.hpp:515:72: note: read of non-constexpr variable 'parser' is not allowed in a constant expression
    auto is_operator = [&parser]() constexpr noexcept -> bool { return parser.current_token.type == range_token_type::range_operator; };
                                                                       ^
/home/runner/work/YAODAQ/YAODAQ/build/_deps/semver-src/include/semver.hpp:511:18: note: declared here
    range_parser parser{str_};
                 ^
/home/runner/work/YAODAQ/YAODAQ/build/_deps/semver-src/include/semver.hpp:517:22: error: constexpr function never produces a constant expression [-Winvalid-constexpr]
    auto is_number = [&parser]() constexpr noexcept -> bool { return parser.current_token.type == range_token_type::number; };
                     ^
/home/runner/work/YAODAQ/YAODAQ/build/_deps/semver-src/include/semver.hpp:517:70: note: read of non-constexpr variable 'parser' is not allowed in a constant expression
    auto is_number = [&parser]() constexpr noexcept -> bool { return parser.current_token.type == range_token_type::number; };
                                                                     ^
/home/runner/work/YAODAQ/YAODAQ/build/_deps/semver-src/include/semver.hpp:511:18: note: declared here
    range_parser parser{str_};
                 ^
/home/runner/work/YAODAQ/YAODAQ/build/_deps/semver-src/include/semver.hpp:581:9: warning: default label in switch which covers all enumeration values [-Wcovered-switch-default]
        default:
        ^
/home/runner/work/YAODAQ/YAODAQ/build/_deps/semver-src/include/semver.hpp:609:53: warning: constructor parameter 'text' shadows the field 'text' of 'range_lexer' [-Wshadow-field-in-constructor]
    constexpr explicit range_lexer(std::string_view text) noexcept : text{text}, pos{0} {}
                                                    ^
/home/runner/work/YAODAQ/YAODAQ/build/_deps/semver-src/include/semver.hpp:606:22: note: previous declaration is here
    std::string_view text;
                     ^
/home/runner/work/YAODAQ/YAODAQ/build/_deps/semver-src/include/semver.hpp:794:3: warning: default label in switch which covers all enumeration values [-Wcovered-switch-default]
  default: