[Bug c++/94409] New: std::regexp (std::collate?) with GCC 7.3.1 on AIX, Japanese

2020-03-30 Thread gcc-bugzilla at vlasiu dot net
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94409

Bug ID: 94409
   Summary: std::regexp (std::collate?) with GCC 7.3.1 on AIX,
Japanese
   Product: gcc
   Version: unknown
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: gcc-bugzilla at vlasiu dot net
  Target Milestone: ---

std::regexp constructor fail on AIX (Japanese). Works fine for English,
Spanish, Italian, French and German languages.

$ gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/opt/freeware/libexec/gcc/powerpc-ibm-aix7.1.0.0/7.3.1/lto-wrapper
Target: powerpc-ibm-aix7.1.0.0
Configured with: ../gcc-7.3.1-20180303/configure --with-as=/usr/bin/as
--with-ld=/usr/bin/ld --enable-languages=c,c++,fortran --prefix=/opt/freeware
--mandir=/opt/freeware/man --infodir=/opt/freeware/info
--enable-version-specific-runtime-libs
--disable-nls --enable-decimal-float=dpd --enable-bootstrap
--build=powerpc-ibm-aix7.1.0.0
Thread model: aix
gcc version 7.3.1 20180303 (GCC) 

The code:

#include 
#include 
#include 

using namespace std;

int main()
{
   char* pLocale = setlocale(LC_ALL, NULL);
   std::cout << "setlocale(): " << pLocale << std::endl;

   const std::regex r1("^(\\s+)?(.*?)(\\s+)?=(\\s+)?(.*?)(\\s+)?");
   std::cout << "std::regex r1: OK" << std::endl;

   setlocale(LC_ALL, "Ja_JP");
   pLocale = setlocale(LC_ALL, NULL);
   std::cout << "setlocale(): " << pLocale << std::endl;

   const std::regex r2("asdf");
   std::cout << "std::regex r2: OK" << std::endl;

   // const std::regex r3("^(\\s+)?(.*?)(\\s+)?=(\\s+)?(.*?)(\\s+)?");
   const std::regex r3("\\s+");
   std::cout << "std::regex r3: OK" << std::endl;

   return 0;
}

The output:

$ ./a.out 
setlocale(): C C C C C C
std::regex r1: OK
setlocale(): Ja_JP Ja_JP Ja_JP Ja_JP Ja_JP Ja_JP
std::regex r2: OK
terminate called after throwing an instance of 'std::length_error'
  what():  basic_string::append
IOT/Abort trap (core dumped)
$

$ gdb -c ./core ./a.out
...
(gdb) backtrace
#0  0x0957ff14 in pthread_kill () from
/usr/lib/libpthreads.a(shr_xpg5_64.o)
#1  0x0957f768 in _p_raise () from
/usr/lib/libpthreads.a(shr_xpg5_64.o)
#2  0x0903956c in raise () from /usr/lib/threads/libc.a(shr_64.o)
#3  0x09055f68 in abort () from /usr/lib/threads/libc.a(shr_64.o)
#4  0x090001c91740 in __gnu_cxx::__verbose_terminate_handler() () from
/usr/lpp/pd/lib64/libstdc++.a(libstdc++.so.6)
#5  0x090001ca0a4c in __cxxabiv1::__terminate(void (*)()) () from
/usr/lpp/pd/lib64/libstdc++.a(libstdc++.so.6)
#6  0x090001c91530 in std::terminate() () from
/usr/lpp/pd/lib64/libstdc++.a(libstdc++.so.6)
#7  0x090001c9fc90 in __cxa_rethrow () from
/usr/lpp/pd/lib64/libstdc++.a(libstdc++.so.6)
#8  0x090001cdbc50 in std::__cxx11::collate::do_transform () from
/usr/lpp/pd/lib64/libstdc++.a(libstdc++.so.6)
#9  0x090001cfea54 in std::__cxx11::collate::transform () from
/usr/lpp/pd/lib64/libstdc++.a(libstdc++.so.6)
#10 0x00010002dba0 in std::__cxx11::basic_string, std::allocator >
std::__cxx11::regex_traits::transform(char*, char*) const ()
#11 0x00010002c6c0 in std::__cxx11::basic_string, std::allocator >
std::__cxx11::regex_traits::transform_primary(char const*,
char const*) const ()
#12 0x00010002ae60 in
std::__detail::_BracketMatcher, false,
false>::_M_apply(char, std::integral_constant)
const::{lambda()#1}::operator()() const ()
#13 0x00010002ab2c in
std::__detail::_BracketMatcher, false,
false>::_M_apply(char, std::integral_constant) const ()
#14 0x00010002a6f8 in
std::__detail::_BracketMatcher, false,
false>::_M_make_cache(std::integral_constant) ()
#15 0x000100026294 in
std::__detail::_BracketMatcher, false,
false>::_M_ready() ()
#16 0x000100022600 in void
std::__detail::_Compiler
>::_M_insert_character_class_matcher() ()
#17 0x000100013208 in
std::__detail::_Compiler >::_M_atom() ()
#18 0x0001000101d8 in
std::__detail::_Compiler >::_M_term() ()
#19 0x000100010028 in
std::__detail::_Compiler >::_M_alternative()
()
#20 0x0001fe48 in
std::__detail::_Compiler >::_M_disjunction()
()#21 0x00012460 in
std::__detail::_Compiler >::_Compiler(char
const*, char const*, std::locale
const&, std::regex_constants::syntax_option_type) ()
#22 0x0001206c in
std::enable_if::value,
std::shared_ptr > const>
>::type std::__detail::__compile_nfa >(char const*, char const*,
std::__cxx11::regex_traits::locale_type const&,
std::regex_constants::syntax_option_type) ()
#23 0x00011e70 in std::__cxx11::basic_regex >::basic_regex(char const*, char
const*, std::locale, std::regex_constants::syn

[Bug libstdc++/94409] std::regexp (std::collate?) with GCC 7.3.1 on AIX, Japanese

2020-03-30 Thread gcc-bugzilla at vlasiu dot net
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94409

--- Comment #2 from gcc-bugzilla at vlasiu dot net ---
(In reply to Jonathan Wakely from comment #1)
> N.B. GCC 7 is no longer supported and will not be fixed (but the bug is also
> present in supported releases).

We are going to switch soon to GCC 8.3.1 or 9.1.1. It would be nice to have a
patch for any of those versions. Thank you.

[Bug libstdc++/94409] std::regexp (std::collate?) with GCC 7.3.1 on AIX, Japanese

2020-03-30 Thread gcc-bugzilla at vlasiu dot net
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94409

--- Comment #4 from gcc-bugzilla at vlasiu dot net ---
That's really bad news for us. Well, we'll wait for a patch and maybe we are
going to backport-it. If it's going to be too complicated we are probably going
to switch to one of the supported versions (we kind of need to be in sync with
RHEL SCL version of GCC).
Thank you.