public inbox for libstdc++@gcc.gnu.org
 help / color / mirror / Atom feed
From: "François Dumont" <frs.dumont@gmail.com>
To: libstdc++@gcc.gnu.org
Subject: Re: trunk -D_GLIBCXX_DEBUG #include <regex> fails
Date: Mon, 9 Aug 2021 14:05:17 +0200	[thread overview]
Message-ID: <5ecf624e-a191-0cd2-19bb-cae92a88cdbf@gmail.com> (raw)
In-Reply-To: <CACb0b4mmDNjeF_HBt46gygMkc32-Xaw9_6nZJ2sWbd1XjoYrTg@mail.gmail.com>

On 09/08/21 12:05 pm, Jonathan Wakely via Libstdc++ wrote:
> On Mon, 9 Aug 2021 at 10:51, Stephan Bergmann via Libstdc++
> <libstdc++@gcc.gnu.org> wrote:
>> 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).
> With that flag the container implementations are defined in namespace
> __gnu_cxx1998, and std::map is supposed to refer to __gnu_debug::map.
> But the debug map is declared in a header which isn't included by
> <regex> since I replaced <map> with <bits/stl_map.h>.
>
>
>
>> 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
>>> +
> I think we can do this instead:
>
> --- a/libstdc++-v3/include/std/regex
> +++ b/libstdc++-v3/include/std/regex
> @@ -63,6 +63,11 @@
> #include <bits/regex.h>
> #include <bits/regex_executor.h>
>
> +#ifdef _GLIBCXX_DEBUG
> +# include <debug/map>
> +# include <debug/vector>
> +#endif
> +
> #if __cplusplus >= 201703L && _GLIBCXX_USE_CXX11_ABI
> namespace std _GLIBCXX_VISIBILITY(default)
> {
>
>
> I'll test it, thanks for the report.
>
We are confident about the usage of those containers in the regex 
implementation, aren't we ?

You can normally avoid the includes if you use for example 
_GLIBCXX_STD_C::map rather than std::map.


  reply	other threads:[~2021-08-09 12:05 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-09  9:50 Stephan Bergmann
2021-08-09 10:05 ` Jonathan Wakely
2021-08-09 12:05   ` François Dumont [this message]
2021-08-09 14:27     ` Jonathan Wakely
2021-08-09 14:42       ` Jonathan Wakely
2021-08-09 19:47         ` Jonathan Wakely
2021-08-10  7:24         ` Stephan Bergmann

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5ecf624e-a191-0cd2-19bb-cae92a88cdbf@gmail.com \
    --to=frs.dumont@gmail.com \
    --cc=libstdc++@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).