hanickadot / compile-time-regular-expressions

Compile Time Regular Expression in C++
https://twitter.com/hankadusikova
Apache License 2.0
3.22k stars 177 forks source link

Build failure with libc++'s debug mode #262

Closed jcelerier closed 1 year ago

jcelerier commented 1 year ago

Godbolt repro: https://gcc.godbolt.org/z/TKKEhEK59

Problem is here:

        template <typename It = Iterator> constexpr CTRE_FORCE_INLINE auto to_view() const noexcept {
            // random access, because C++ (waving hands around)
            constexpr bool must_be_nonreverse_contiguous_iterator = is_random_accessible(typename std::iterator_traits<std::remove_const_t<It>>::iterator_category{}) && !is_reverse_iterator(It{});

            static_assert(must_be_nonreverse_contiguous_iterator, "To convert capture into a basic_string_view you need to provide a pointer or a contiguous non-reverse iterator/range to regex.");

            return std::basic_string_view<char_type>(data_unsafe(), static_cast<size_t>(unit_size()));
        }

it complains that:

In file included from ctre.hpp:4:
In file included from ctre/literals.hpp:6:
In file included from ctre/evaluation.hpp:9:
ctre/return_type.hpp:124:18: error: static_assert expression is not an integral constant expression
                        static_assert(must_be_nonreverse_contiguous_iterator, "To convert capture into a basic_string_view you need to provide a pointer or a contiguous non-reverse iterator/range to regex.");
                                      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
ctre/return_type.hpp:124:18: note: initializer of 'must_be_nonreverse_contiguous_iterator' is not a constant expression
ctre/return_type.hpp:122:19: note: declared here
                        constexpr bool must_be_nonreverse_contiguous_iterator = is_random_accessible(typename std::iterator_traits<std::remove_const_t<It>>::iterator_category{}) && !is_reverse_iterator(It{});
                                       ^
jcelerier commented 1 year ago

Maybe the simplest for now would be disabling those compile-time tests if this macro is defined as it's unlikely that a project would only ever build with _LIBCPP_DEBUG=1 thus an user error would likely be triggered by another build from the build matrix

hanickadot commented 1 year ago

Should be fixed now in latest main.

jcelerier commented 1 year ago

neat, thanks!