public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libstdc++/66359] New: Regex Fails to match
@ 2015-06-01  9:53 georg@schorsch-tech.de
  2015-06-01  9:54 ` [Bug libstdc++/66359] " georg@schorsch-tech.de
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: georg@schorsch-tech.de @ 2015-06-01  9:53 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66359

            Bug ID: 66359
           Summary: Regex Fails to match
           Product: gcc
           Version: 4.9.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libstdc++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: georg@schorsch-tech.de
  Target Milestone: ---

// #define USE_STD

#ifdef USE_STD
#include <regex>
#else
#include <boost/regex.hpp>
#endif

#include <iostream>
#include <string>

#ifdef USE_STD
namespace rx = std;
#else
namespace rx = boost;
#endif

int main(int argc, char* argv[])
{
        std::string line{ "Name:\tPiko_10_1  " };
        rx::regex line_expression("^Name:\t {0,2}([a-zA-Z_0-9-]{1,20})
{0,20}$");
        rx::match_results<std::string::const_iterator> line_what;
        if (rx::regex_match(line, line_what, line_expression))
        {
                std::cout << "Found it" << std::endl;
        }
        else
        {
                std::cout << "ERROR: Did not find it" << std::endl;
                return 1;
        }

        return 0;
}

Compile with:
std: g++ --std=c++11 main.cpp -o test-std.exe
Boost: g++ --std=c++11 main.cpp -o test-boost.exe -I PATH_TO_BOOST_INCLUDE _L
PATH_TO_BOOST_REGEX_LIB

I tried to convert an application from boost:.regex to std::regex. This example
is the boiled down example from my application.

With the define USE_STD defined, i get the error that this regex doesnt match.
With boost::regex i get a match. I tried this regex on TDM-GCC-4.9.2 and on
Linux gcc-4.9.2 (gentoo). 

I know regex is not implemented Prior 4.9.0. I am on 4.9.2 so i guess it should
work. Other regexes like
std::regex line_expression("([a-zA-Z_]+) ?= ?([a-zA-Z0-9./]+)");
work as expected.


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug libstdc++/66359] Regex Fails to match
  2015-06-01  9:53 [Bug libstdc++/66359] New: Regex Fails to match georg@schorsch-tech.de
@ 2015-06-01  9:54 ` georg@schorsch-tech.de
  2015-06-01 11:46 ` timshen at gcc dot gnu.org
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: georg@schorsch-tech.de @ 2015-06-01  9:54 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66359

--- Comment #1 from georg@schorsch-tech.de ---
The example main.cpp from abouve works on other Compilers like MSVC-2013
(VS12).


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug libstdc++/66359] Regex Fails to match
  2015-06-01  9:53 [Bug libstdc++/66359] New: Regex Fails to match georg@schorsch-tech.de
  2015-06-01  9:54 ` [Bug libstdc++/66359] " georg@schorsch-tech.de
@ 2015-06-01 11:46 ` timshen at gcc dot gnu.org
  2015-06-01 15:19 ` georg@schorsch-tech.de
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: timshen at gcc dot gnu.org @ 2015-06-01 11:46 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66359

Tim Shen <timshen at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |ASSIGNED
   Last reconfirmed|                            |2015-06-01
                 CC|                            |timshen at gcc dot gnu.org
     Ever confirmed|0                           |1

--- Comment #2 from Tim Shen <timshen at gcc dot gnu.org> ---
Thanks for reporting! gcc 5.1 works fine to me:

~ % /usr/bin/g++ --version                           
g++ (GCC) 5.1.0
Copyright (C) 2015 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

~ % /usr/bin/g++ -DUSE_STD -std=c++11 b.cc && ./a.out
Found it


My current guess is this patch fixed the bug:
https://gcc.gnu.org/viewcvs/gcc?view=revision&revision=217461.

I can do a backport when I have time.


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug libstdc++/66359] Regex Fails to match
  2015-06-01  9:53 [Bug libstdc++/66359] New: Regex Fails to match georg@schorsch-tech.de
  2015-06-01  9:54 ` [Bug libstdc++/66359] " georg@schorsch-tech.de
  2015-06-01 11:46 ` timshen at gcc dot gnu.org
@ 2015-06-01 15:19 ` georg@schorsch-tech.de
  2015-06-01 15:25 ` georg@schorsch-tech.de
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: georg@schorsch-tech.de @ 2015-06-01 15:19 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66359

--- Comment #3 from georg@schorsch-tech.de ---
I tried to apply that revision to gcc-4.9.2. Now i get the following error.

g++ -DUSE_STD -std=c++11 main.cpp 
In file included from
/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.2/include/g++-v4/regex:58:0,
                 from main.cpp:2:
/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.2/include/g++-v4/bits/regex.h:65:5:
warning: inline function 'std::shared_ptr<std::__detail::_NFA<_TraitsT> >
std::__detail::__compile_nfa(const typename _TraitsT::char_type*, const
typename _TraitsT::char_type*, const _TraitsT&,
std::regex_constants::syntax_option_type) [with _TraitsT =
std::regex_traits<char>; typename _TraitsT::char_type = char]' used but never
defined
     __compile_nfa(const typename _TraitsT::char_type* __first,
     ^
/tmp/ccMywN21.o: In function `std::basic_regex<char, std::regex_traits<char>
>::basic_regex<char const*>(char const*, char const*,
std::regex_constants::syntax_option_type)':
main.cpp:(.text._ZNSt11basic_regexIcSt12regex_traitsIcEEC2IPKcEET_S6_NSt15regex_constants18syntax_option_typeE[_ZNSt11basic_regexIcSt12regex_traitsIcEEC5IPKcEET_S6_NSt15regex_constants18syntax_option_typeE]+0xd5):
undefined reference to
`std::shared_ptr<std::__detail::_NFA<std::regex_traits<char> > >
std::__detail::__compile_nfa<std::regex_traits<char>
>(std::regex_traits<char>::char_type const*, std::regex_traits<char>::char_type
const*, std::regex_traits<char> const&,
std::regex_constants::syntax_option_type)'
collect2: error: ld returned 1 exit status


I added my applied patch too. I copied the files from your revision to my tree
and used git to create that patch.


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug libstdc++/66359] Regex Fails to match
  2015-06-01  9:53 [Bug libstdc++/66359] New: Regex Fails to match georg@schorsch-tech.de
                   ` (2 preceding siblings ...)
  2015-06-01 15:19 ` georg@schorsch-tech.de
@ 2015-06-01 15:25 ` georg@schorsch-tech.de
  2015-06-05  4:59 ` timshen at gcc dot gnu.org
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: georg@schorsch-tech.de @ 2015-06-01 15:25 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66359

--- Comment #4 from georg@schorsch-tech.de ---
Created attachment 35666
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=35666&action=edit
tried backport of 217461


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug libstdc++/66359] Regex Fails to match
  2015-06-01  9:53 [Bug libstdc++/66359] New: Regex Fails to match georg@schorsch-tech.de
                   ` (3 preceding siblings ...)
  2015-06-01 15:25 ` georg@schorsch-tech.de
@ 2015-06-05  4:59 ` timshen at gcc dot gnu.org
  2015-06-05  5:06 ` timshen at gcc dot gnu.org
  2023-07-20 11:47 ` redi at gcc dot gnu.org
  6 siblings, 0 replies; 8+ messages in thread
From: timshen at gcc dot gnu.org @ 2015-06-05  4:59 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66359

--- Comment #5 from Tim Shen <timshen at gcc dot gnu.org> ---
Author: timshen
Date: Fri Jun  5 04:58:26 2015
New Revision: 224144

URL: https://gcc.gnu.org/viewcvs?rev=224144&root=gcc&view=rev
Log:
        PR libstdc++/66359
        Backport from mainline
        2014-11-13  Tim Shen  <timshen@google.com>

        PR libstdc++/63775
        * include/bits/regex_compiler.h (_Compiler<>::_M_expression_term,
        _BracketMatcher<>::_M_make_range): Throw regex_erorr on invalid range
        like [z-a]. Change _M_expression_term interface.
        * include/bits/regex_compiler.tcc (
        _Compiler<>::_M_insert_bracket_matcher,
        _Compiler<>::_M_expression_term): Rewrite bracket expression parsing.
        * testsuite/28_regex/algorithms/regex_match/cstring_bracket_01.cc:
        Add testcases and move file out of extended.

Added:
   
branches/gcc-4_9-branch/libstdc++-v3/testsuite/28_regex/algorithms/regex_match/cstring_bracket_01.cc
Removed:
   
branches/gcc-4_9-branch/libstdc++-v3/testsuite/28_regex/algorithms/regex_match/extended/cstring_bracket_01.cc
Modified:
    branches/gcc-4_9-branch/libstdc++-v3/ChangeLog
    branches/gcc-4_9-branch/libstdc++-v3/include/bits/regex_compiler.h
    branches/gcc-4_9-branch/libstdc++-v3/include/bits/regex_compiler.tcc


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug libstdc++/66359] Regex Fails to match
  2015-06-01  9:53 [Bug libstdc++/66359] New: Regex Fails to match georg@schorsch-tech.de
                   ` (4 preceding siblings ...)
  2015-06-05  4:59 ` timshen at gcc dot gnu.org
@ 2015-06-05  5:06 ` timshen at gcc dot gnu.org
  2023-07-20 11:47 ` redi at gcc dot gnu.org
  6 siblings, 0 replies; 8+ messages in thread
From: timshen at gcc dot gnu.org @ 2015-06-05  5:06 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66359

Tim Shen <timshen at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|---                         |FIXED

--- Comment #6 from Tim Shen <timshen at gcc dot gnu.org> ---
Fixed.


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug libstdc++/66359] Regex Fails to match
  2015-06-01  9:53 [Bug libstdc++/66359] New: Regex Fails to match georg@schorsch-tech.de
                   ` (5 preceding siblings ...)
  2015-06-05  5:06 ` timshen at gcc dot gnu.org
@ 2023-07-20 11:47 ` redi at gcc dot gnu.org
  6 siblings, 0 replies; 8+ messages in thread
From: redi at gcc dot gnu.org @ 2023-07-20 11:47 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66359

Jonathan Wakely <redi at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|---                         |4.9.3

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2023-07-20 11:47 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-06-01  9:53 [Bug libstdc++/66359] New: Regex Fails to match georg@schorsch-tech.de
2015-06-01  9:54 ` [Bug libstdc++/66359] " georg@schorsch-tech.de
2015-06-01 11:46 ` timshen at gcc dot gnu.org
2015-06-01 15:19 ` georg@schorsch-tech.de
2015-06-01 15:25 ` georg@schorsch-tech.de
2015-06-05  4:59 ` timshen at gcc dot gnu.org
2015-06-05  5:06 ` timshen at gcc dot gnu.org
2023-07-20 11:47 ` redi at gcc dot gnu.org

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).