string::iterator should have more error checking
Jonathan Wakely
jwakely@redhat.com
Thu Jun 23 22:35:51 GMT 2022
On Thu, 23 Jun 2022 at 23:01, Frederick Virchanza Gotham via Libstdc++
<libstdc++@gcc.gnu.org> wrote:
>
> On Thu, Jun 23, 2022 at 10:26 PM Jonathan Wakely <jwakely@redhat.com> wrote:
>
> > AddressSanitizer does give an error for your example though.
>
>
> If you're talking about using "g++" with the command line option
> "-fsanitize=address", well I've tested it and it **doesn't** give an
> error for my sample program.
Yes it does:
https://godbolt.org/z/hYhcfjTWY
>
> I thought that "-D_GLIBCXX_DEBUG" would make it use
> "__gnu_debug::string". So are you saying that I'll have to do the
> following in my code?
>
> #ifdef NDEBUG
> #include <string>
> typedef std::string string;
> #else
> #include <debug/string>
> typedef __gnu_debug::string string;
> #endif
>
> Is this what I'm supposed to do?
Yes, for full Debug Mode checks you need to use __gnu_debug::string,
as documented in the manual.
More information about the Libstdc++
mailing list