Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

infinite loop while building a dfa #80

Open
nakrakiiya opened this issue Jan 2, 2025 · 0 comments
Open

infinite loop while building a dfa #80

nakrakiiya opened this issue Jan 2, 2025 · 0 comments

Comments

@nakrakiiya
Copy link

Version: latest in vcpkg (2024.12)
Compiler: Microsoft (R) C/C++ Optimizing Compiler Version 19.42.34435 for x64 (latest msvc)

Code to reproduce:

#include <ctpg/ctpg.hpp>
#include <utility>

constexpr char id_pattern[] = "[_A-Za-z][_A-Za-z0-9]*";
constexpr ctpg::regex_term<id_pattern> id("identifier");

constexpr char function_like_name_with_lparen_pattern[] = "[_A-Za-z][_A-Za-z0-9]*\\(";
constexpr ctpg::regex_term<function_like_name_with_lparen_pattern> function_like_name_with_lparen("function_like_name_with_lparen");

constexpr ctpg::nterm<std::string> line("line");

constexpr ctpg::parser parser(
    line,
    terms(function_like_name_with_lparen, id),
    nterms(line),
    rules(line(id) >= std::identity {}));

Fail to compile with message:

C:\PROGRA~1\MIB055~1\2022\ENTERP~1\VC\Tools\MSVC\1442~1.344\bin\Hostx64\x64\cl.exe  /nologo /TP -D_CRT_SECURE_NO_WARNINGS -ID:\source\expand\src\utils -external:ID:\source\expand\out\build\Debug\vcpkg_installed\x64-windows\include -external:W0 /DWIN32 /D_WINDOWS /EHsc /Ob0 /Od /RTC1 -std:c++latest -MDd -Zi -utf-8 -W4 /showIncludes @expand\CMakeFiles\expand.dir\bug.cpp.obj.modmap /Foexpand\CMakeFiles\expand.dir\bug.cpp.obj /Fdexpand\CMakeFiles\expand.dir\ /FS -c D:\source\expand\src\expand\bug.cpp
D:\source\expand\src\expand\bug.cpp(12): error C2131: expression did not evaluate to a constant
D:\source\expand\out\build\Debug\vcpkg_installed\x64-windows\include\ctpg/ctpg.hpp(1293): note: failure was caused by evaluation exceeding call depth limit of 512 (/constexpr:depth<NUMBER>)
D:\source\expand\src\expand\bug.cpp(12): note: the call stack of the evaluation (the oldest call first) is
D:\source\expand\src\expand\bug.cpp(12): note: while evaluating function 'ctpg::parser<ctpg::nterm<std::string>,std::tuple<ctpg::regex_term<& function_like_name_with_lparen_pattern>,ctpg::regex_term<& id_pattern>>,std::tuple<ctpg::nterm<std::string>>,std::tuple<ctpg::detail::rule<false,std::identity,ctpg::nterm<std::string>,ctpg::regex_term<& id_pattern>>>,ctpg::use_generated_lexer>::parser(ctpg::nterm<std::string>,std::tuple<ctpg::regex_term<& function_like_name_with_lparen_pattern>,ctpg::regex_term<& id_pattern>>,std::tuple<ctpg::nterm<std::string>>,std::tuple<ctpg::detail::rule<false,std::identity,ctpg::nterm<std::string>,ctpg::regex_term<& id_pattern>>> &&)'
D:\source\expand\out\build\Debug\vcpkg_installed\x64-windows\include\ctpg/ctpg.hpp(1869): note: while evaluating function 'void ctpg::parser<ctpg::nterm<std::string>,std::tuple<ctpg::regex_term<& function_like_name_with_lparen_pattern>,ctpg::regex_term<& id_pattern>>,std::tuple<ctpg::nterm<std::string>>,std::tuple<ctpg::detail::rule<false,std::identity,ctpg::nterm<std::string>,ctpg::regex_term<& id_pattern>>>,ctpg::use_generated_lexer>::create_lexer<0,1>(std::integer_sequence<size_t,0,1>)'
D:\source\expand\out\build\Debug\vcpkg_installed\x64-windows\include\ctpg/ctpg.hpp(2858): note: while evaluating function 'void ctpg::regex::add_term_data_to_dfa<10,ctpg::parser<ctpg::nterm<ctpg::regex::create_regex_parser::slice>,std::tuple<ctpg::custom_term<ctpg::regex::create_regex_parser::<lambda_1>>,ctpg::custom_term<ctpg::regex::char_subset (__cdecl *)(std::string_view)>,ctpg::char_term,ctpg::char_term,ctpg::char_term,ctpg::char_term,ctpg::char_term,ctpg::char_term,ctpg::char_term,ctpg::char_term>,std::tuple<ctpg::nterm<ctpg::regex::create_regex_parser::slice>,ctpg::nterm<ctpg::regex::create_regex_parser::slice>,ctpg::nterm<ctpg::regex::create_regex_parser::slice>,ctpg::nterm<ctpg::regex::create_regex_parser::slice>,ctpg::nterm<ctpg::regex::create_regex_parser::slice>,ctpg::nterm<ctpg::size32_t>>,std::tuple<ctpg::detail::rule<false,std::nullptr_t,ctpg::nterm<ctpg::size32_t>,ctpg::custom_term<ctpg::regex::create_regex_parser::<lambda_1>>>,ctpg::detail::rule<false,ctpg::regex::create_regex_parser::<lambda_2>,ctpg::nterm<ctpg::size32_t>,ctpg::nterm<ctpg::size32_t>,ctpg::custom_term<ctpg::regex::create_regex_parser::<lambda_1>>>,ctpg::detail::rule<false,ctpg::regex::create_regex_parser::<lambda_3>,ctpg::nterm<ctpg::regex::create_regex_parser::slice>,ctpg::custom_term<ctpg::regex::create_regex_parser::<lambda_1>>>,ctpg::detail::rule<false,ctpg::regex::create_regex_parser::<lambda_4>,ctpg::nterm<ctpg::regex::create_regex_parser::slice>,ctpg::custom_term<ctpg::regex::char_subset (__cdecl *)(std::string_view)>>,ctpg::detail::rule<false,ctpg::ftors::element<2,std::integer_sequence<size_t,0>>,ctpg::nterm<ctpg::regex::create_regex_parser::slice>,ctpg::char_term,ctpg::nterm<ctpg::regex::create_regex_parser::slice>,ctpg::char_term>,ctpg::detail::rule<false,std::nullptr_t,ctpg::nterm<ctpg::regex::create_regex_parser::slice>,ctpg::nterm<ctpg::regex::create_regex_parser::slice>>,ctpg::detail::rule<false,ctpg::regex::create_regex_parser::<lambda_5>,ctpg::nterm<ctpg::regex::create_regex_parser::slice>,ctpg::nterm<ctpg::regex::create_regex_parser::slice>,ctpg::char_term>,ctpg::detail::rule<false,ctpg::regex::create_regex_parser::<lambda_6>,ctpg::nterm<ctpg::regex::create_regex_parser::slice>,ctpg::nterm<ctpg::regex::create_regex_parser::slice>,ctpg::char_term>,ctpg::detail::rule<false,ctpg::regex::create_regex_parser::<lambda_7>,ctpg::nterm<ctpg::regex::create_regex_parser::slice>,ctpg::nterm<ctpg::regex::create_regex_parser::slice>,ctpg::char_term>,ctpg::detail::rule<false,ctpg::regex::create_regex_parser::<lambda_8>,ctpg::nterm<ctpg::regex::create_regex_parser::slice>,ctpg::nterm<ctpg::regex::create_regex_parser::slice>,ctpg::char_term,ctpg::nterm<ctpg::size32_t>,ctpg::char_term>,ctpg::detail::rule<false,std::nullptr_t,ctpg::nterm<ctpg::regex::create_regex_parser::slice>,ctpg::nterm<ctpg::regex::create_regex_parser::slice>>,ctpg::detail::rule<false,ctpg::regex::create_regex_parser::<lambda_9>,ctpg::nterm<ctpg::regex::create_regex_parser::slice>,ctpg::nterm<ctpg::regex::create_regex_parser::slice>,ctpg::nterm<ctpg::regex::create_regex_parser::slice>>,ctpg::detail::rule<false,std::nullptr_t,ctpg::nterm<ctpg::regex::create_regex_parser::slice>,ctpg::nterm<ctpg::regex::create_regex_parser::slice>>,ctpg::detail::rule<false,ctpg::regex::create_regex_parser::<lambda_10>,ctpg::nterm<ctpg::regex::create_regex_parser::slice>,ctpg::nterm<ctpg::regex::create_regex_parser::slice>,ctpg::char_term,ctpg::nterm<ctpg::regex::create_regex_parser::slice>>,ctpg::detail::rule<false,std::nullptr_t,ctpg::nterm<ctpg::regex::create_regex_parser::slice>,ctpg::nterm<ctpg::regex::create_regex_parser::slice>>>,ctpg::use_lexer<ctpg::regex::regex_lexer>>,23>(const ctpg::regex::regex_pattern_data<23> &,ctpg::regex::dfa_builder<10> &,const Parser &,ctpg::size16_t)'
        with
        [
            Parser=ctpg::parser<ctpg::nterm<ctpg::regex::create_regex_parser::slice>,std::tuple<ctpg::custom_term<ctpg::regex::create_regex_parser::<lambda_1>>,ctpg::custom_term<ctpg::regex::char_subset (__cdecl *)(std::string_view)>,ctpg::char_term,ctpg::char_term,ctpg::char_term,ctpg::char_term,ctpg::char_term,ctpg::char_term,ctpg::char_term,ctpg::char_term>,std::tuple<ctpg::nterm<ctpg::regex::create_regex_parser::slice>,ctpg::nterm<ctpg::regex::create_regex_parser::slice>,ctpg::nterm<ctpg::regex::create_regex_parser::slice>,ctpg::nterm<ctpg::regex::create_regex_parser::slice>,ctpg::nterm<ctpg::regex::create_regex_parser::slice>,ctpg::nterm<ctpg::size32_t>>,std::tuple<ctpg::detail::rule<false,std::nullptr_t,ctpg::nterm<ctpg::size32_t>,ctpg::custom_term<ctpg::regex::create_regex_parser::<lambda_1>>>,ctpg::detail::rule<false,ctpg::regex::create_regex_parser::<lambda_2>,ctpg::nterm<ctpg::size32_t>,ctpg::nterm<ctpg::size32_t>,ctpg::custom_term<ctpg::regex::create_regex_parser::<lambda_1>>>,ctpg::detail::rule<false,ctpg::regex::create_regex_parser::<lambda_3>,ctpg::nterm<ctpg::regex::create_regex_parser::slice>,ctpg::custom_term<ctpg::regex::create_regex_parser::<lambda_1>>>,ctpg::detail::rule<false,ctpg::regex::create_regex_parser::<lambda_4>,ctpg::nterm<ctpg::regex::create_regex_parser::slice>,ctpg::custom_term<ctpg::regex::char_subset (__cdecl *)(std::string_view)>>,ctpg::detail::rule<false,ctpg::ftors::element<2,std::integer_sequence<size_t,0>>,ctpg::nterm<ctpg::regex::create_regex_parser::slice>,ctpg::char_term,ctpg::nterm<ctpg::regex::create_regex_parser::slice>,ctpg::char_term>,ctpg::detail::rule<false,std::nullptr_t,ctpg::nterm<ctpg::regex::create_regex_parser::slice>,ctpg::nterm<ctpg::regex::create_regex_parser::slice>>,ctpg::detail::rule<false,ctpg::regex::create_regex_parser::<lambda_5>,ctpg::nterm<ctpg::regex::create_regex_parser::slice>,ctpg::nterm<ctpg::regex::create_regex_parser::slice>,ctpg::char_term>,ctpg::detail::rule<false,ctpg::regex::create_regex_parser::<lambda_6>,ctpg::nterm<ctpg::regex::create_regex_parser::slice>,ctpg::nterm<ctpg::regex::create_regex_parser::slice>,ctpg::char_term>,ctpg::detail::rule<false,ctpg::regex::create_regex_parser::<lambda_7>,ctpg::nterm<ctpg::regex::create_regex_parser::slice>,ctpg::nterm<ctpg::regex::create_regex_parser::slice>,ctpg::char_term>,ctpg::detail::rule<false,ctpg::regex::create_regex_parser::<lambda_8>,ctpg::nterm<ctpg::regex::create_regex_parser::slice>,ctpg::nterm<ctpg::regex::create_regex_parser::slice>,ctpg::char_term,ctpg::nterm<ctpg::size32_t>,ctpg::char_term>,ctpg::detail::rule<false,std::nullptr_t,ctpg::nterm<ctpg::regex::create_regex_parser::slice>,ctpg::nterm<ctpg::regex::create_regex_parser::slice>>,ctpg::detail::rule<false,ctpg::regex::create_regex_parser::<lambda_9>,ctpg::nterm<ctpg::regex::create_regex_parser::slice>,ctpg::nterm<ctpg::regex::create_regex_parser::slice>,ctpg::nterm<ctpg::regex::create_regex_parser::slice>>,ctpg::detail::rule<false,std::nullptr_t,ctpg::nterm<ctpg::regex::create_regex_parser::slice>,ctpg::nterm<ctpg::regex::create_regex_parser::slice>>,ctpg::detail::rule<false,ctpg::regex::create_regex_parser::<lambda_10>,ctpg::nterm<ctpg::regex::create_regex_parser::slice>,ctpg::nterm<ctpg::regex::create_regex_parser::slice>,ctpg::char_term,ctpg::nterm<ctpg::regex::create_regex_parser::slice>>,ctpg::detail::rule<false,std::nullptr_t,ctpg::nterm<ctpg::regex::create_regex_parser::slice>,ctpg::nterm<ctpg::regex::create_regex_parser::slice>>>,ctpg::use_lexer<ctpg::regex::regex_lexer>>
        ]
D:\source\expand\out\build\Debug\vcpkg_installed\x64-windows\include\ctpg/ctpg.hpp(1392): note: while evaluating function 'ctpg::regex::dfa_builder<10>::slice ctpg::regex::dfa_builder<10>::alt(ctpg::regex::dfa_builder<10>::slice,ctpg::regex::dfa_builder<10>::slice)'
D:\source\expand\out\build\Debug\vcpkg_installed\x64-windows\include\ctpg/ctpg.hpp(1275): note: while evaluating function 'void ctpg::regex::dfa_builder<10>::merge(ctpg::size_t,ctpg::size_t,bool,bool)'
D:\source\expand\out\build\Debug\vcpkg_installed\x64-windows\include\ctpg/ctpg.hpp(1315): note: while evaluating function 'void ctpg::regex::dfa_builder<10>::merge(ctpg::size_t,ctpg::size_t,bool,bool)'
D:\source\expand\out\build\Debug\vcpkg_installed\x64-windows\include\ctpg/ctpg.hpp(1315): note: while evaluating function 'void ctpg::regex::dfa_builder<10>::merge(ctpg::size_t,ctpg::size_t,bool,bool)'
D:\source\expand\out\build\Debug\vcpkg_installed\x64-windows\include\ctpg/ctpg.hpp(1315): note: while evaluating function 'void ctpg::regex::dfa_builder<10>::merge(ctpg::size_t,ctpg::size_t,bool,bool)'
D:\source\expand\out\build\Debug\vcpkg_installed\x64-windows\include\ctpg/ctpg.hpp(1315): note: while evaluating function 'void ctpg::regex::dfa_builder<10>::merge(ctpg::size_t,ctpg::size_t,bool,bool)'
D:\source\expand\out\build\Debug\vcpkg_installed\x64-windows\include\ctpg/ctpg.hpp(1315): note: while evaluating function 'void ctpg::regex::dfa_builder<10>::merge(ctpg::size_t,ctpg::size_t,bool,bool)'
D:\source\expand\out\build\Debug\vcpkg_installed\x64-windows\include\ctpg/ctpg.hpp(1315): note: while evaluating function 'void ctpg::regex::dfa_builder<10>::merge(ctpg::size_t,ctpg::size_t,bool,bool)'
D:\source\expand\out\build\Debug\vcpkg_installed\x64-windows\include\ctpg/ctpg.hpp(1315): note: while evaluating function 'void ctpg::regex::dfa_builder<10>::merge(ctpg::size_t,ctpg::size_t,bool,bool)'
D:\source\expand\out\build\Debug\vcpkg_installed\x64-windows\include\ctpg/ctpg.hpp(1315): note: while evaluating function 'void ctpg::regex::dfa_builder<10>::merge(ctpg::size_t,ctpg::size_t,bool,bool)'
... (same as above)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant