trunk -D_GLIBCXX_DEBUG #include <regex> fails

Stephan Bergmann sbergman@redhat.com
Mon Aug 9 09:50:38 GMT 2021


Not sure why I started to experience this now with a recent 
GCC/libstdc++ trunk build:

> $ cat test.cc
> #include <regex>

> $ gcc/trunk/inst/bin/g++ -D_GLIBCXX_DEBUG -fsyntax-only test.cc
> In file included from /home/sbergman/gcc/trunk/inst/include/c++/12.0.0/bits/regex_automaton.h:401,
>                  from /home/sbergman/gcc/trunk/inst/include/c++/12.0.0/regex:60,
>                  from test.cc:1:
> /home/sbergman/gcc/trunk/inst/include/c++/12.0.0/bits/regex_automaton.tcc: In member function ‘std::__detail::_StateSeq<_TraitsT> std::__detail::_StateSeq<_TraitsT>::_M_clone()’:
> /home/sbergman/gcc/trunk/inst/include/c++/12.0.0/bits/regex_automaton.tcc:197:12: error: ‘map’ is not a member of ‘std’
>   197 |       std::map<_StateIdT, _StateIdT> __m;
>       |            ^~~
[...]
> In file included from /home/sbergman/gcc/trunk/inst/include/c++/12.0.0/regex:62,
>                  from test.cc:1:
> /home/sbergman/gcc/trunk/inst/include/c++/12.0.0/bits/regex_compiler.h: At global scope:
> /home/sbergman/gcc/trunk/inst/include/c++/12.0.0/bits/regex_compiler.h:541:12: error: ‘vector’ in namespace ‘std’ does not name a template type
>   541 |       std::vector<_CharT>                       _M_char_set;
>       |            ^~~~~~
[...]

where neither the use of std::map in bits/regex_automaton.tcc nor the 
use of std::vector in bits/regex_compiler.h are in _GLIBCXX_DEBUG-only 
code (but compiling without -D_GLIBCXX_DEBUG succeeded).

Anyway, what would apparently fix it for me is

> diff --git a/libstdc++-v3/include/std/regex b/libstdc++-v3/include/std/regex
> index 04fb8b2d971..29fd2956fd0 100644
> --- a/libstdc++-v3/include/std/regex
> +++ b/libstdc++-v3/include/std/regex
> @@ -42,6 +42,11 @@
>  #include <stdexcept>
>  #include <string>
>  
> +#if defined _GLIBCXX_DEBUG
> +#include <map>
> +#include <vector>
> +#endif
> +
>  #include <ext/aligned_buffer.h>
>  #include <ext/numeric_traits.h>
>  #include <bits/shared_ptr.h>



More information about the Gcc-patches mailing list