[Bug libstdc++/78236] regex_iterator constructor is incomplete and creates uninitialized values that may be used

2017-05-18 Thread redi at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78236

Jonathan Wakely  changed:

   What|Removed |Added

   Target Milestone|--- |5.5

--- Comment #7 from Jonathan Wakely  ---
Fixed in 5.5, 6.4 and 7.1

[Bug libstdc++/78236] regex_iterator constructor is incomplete and creates uninitialized values that may be used

2017-05-18 Thread redi at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78236

--- Comment #6 from Jonathan Wakely  ---
Author: redi
Date: Thu May 18 15:30:42 2017
New Revision: 248230

URL: https://gcc.gnu.org/viewcvs?rev=248230=gcc=rev
Log:
libstdc++/78236 fix past-the-end std::regex_iterator

Backport from mainline
2016-11-09  Tim Shen  

PR libstdc++/78236
* libstdc++-v3/include/bits/regex.h (regex_iterator::regex_iterator()):
Define end() as _M_pregex == nullptr.
* libstdc++-v3/include/bits/regex.tcc (regex_iterator::operator==(),
regex_iterator::operator++()): Fix operator==() and operator++() to
look at null-ness of _M_pregex on both sides.
* testsuite/28_regex/regression.cc: New testcase.

Modified:
branches/gcc-5-branch/libstdc++-v3/ChangeLog
branches/gcc-5-branch/libstdc++-v3/include/bits/regex.h
branches/gcc-5-branch/libstdc++-v3/include/bits/regex.tcc
branches/gcc-5-branch/libstdc++-v3/testsuite/28_regex/regression.cc

[Bug libstdc++/78236] regex_iterator constructor is incomplete and creates uninitialized values that may be used

2017-05-18 Thread redi at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78236

--- Comment #5 from Jonathan Wakely  ---
Author: redi
Date: Thu May 18 14:34:50 2017
New Revision: 248207

URL: https://gcc.gnu.org/viewcvs?rev=248207=gcc=rev
Log:
libstdc++/78236 fix past-the-end std::regex_iterator

Backport from mainline
2016-11-09  Tim Shen  

PR libstdc++/78236
* libstdc++-v3/include/bits/regex.h (regex_iterator::regex_iterator()):
Define end() as _M_pregex == nullptr.
* libstdc++-v3/include/bits/regex.tcc (regex_iterator::operator==(),
regex_iterator::operator++()): Fix operator==() and operator++() to
look at null-ness of _M_pregex on both sides.
* testsuite/28_regex/regression.cc: New testcase.

Modified:
branches/gcc-6-branch/libstdc++-v3/ChangeLog
branches/gcc-6-branch/libstdc++-v3/include/bits/regex.h
branches/gcc-6-branch/libstdc++-v3/include/bits/regex.tcc
branches/gcc-6-branch/libstdc++-v3/testsuite/28_regex/regression.cc

[Bug libstdc++/78236] regex_iterator constructor is incomplete and creates uninitialized values that may be used

2016-11-09 Thread timshen at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78236

Tim Shen  changed:

   What|Removed |Added

 Status|NEW |RESOLVED
 Resolution|--- |FIXED

--- Comment #4 from Tim Shen  ---
Committed fix as r242025.

[Bug libstdc++/78236] regex_iterator constructor is incomplete and creates uninitialized values that may be used

2016-11-07 Thread christophe.monat at st dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78236

--- Comment #3 from Christophe Monat  ---
(In reply to Tim Shen from comment #2)
> I proposed another way to fix this in the list:
> https://gcc.gnu.org/ml/libstdc++/2016-11/msg8.html

Looks perfect - I was somewhat annoyed by the _M_match() call anyway.

The test case is a reconstruction from a much bigger one exhibiting an issue
that we encountered at first on ARM/AArch64.

[Bug libstdc++/78236] regex_iterator constructor is incomplete and creates uninitialized values that may be used

2016-11-07 Thread timshen at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78236

Tim Shen  changed:

   What|Removed |Added

 CC||timshen at gcc dot gnu.org

--- Comment #2 from Tim Shen  ---
(In reply to Christophe Monat from comment #1)
> Comment on attachment 39982 [details]
> Proposed patch to fix the regex_iterator constructor
> 
> >diff --git a/libstdc++-v3/include/bits/regex.h 
> >b/libstdc++-v3/include/bits/regex.h
> >index a7d45e6..bb0a167 100644
> >--- a/libstdc++-v3/include/bits/regex.h
> >+++ b/libstdc++-v3/include/bits/regex.h
> >@@ -2454,7 +2454,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11
> >* one-past-the-end of a range.
> >*/
> >   regex_iterator()
> >-  : _M_match()
> >+  : _M_pregex(), _M_flags(regex_constants::match_default), _M_match()
> >   { }
> > 
> >   /**

I proposed another way to fix this in the list:
https://gcc.gnu.org/ml/libstdc++/2016-11/msg8.html

[Bug libstdc++/78236] regex_iterator constructor is incomplete and creates uninitialized values that may be used

2016-11-07 Thread redi at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78236

Jonathan Wakely  changed:

   What|Removed |Added

 Status|UNCONFIRMED |NEW
   Last reconfirmed||2016-11-07
 Ever confirmed|0   |1

[Bug libstdc++/78236] regex_iterator constructor is incomplete and creates uninitialized values that may be used

2016-11-07 Thread christophe.monat at st dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78236

--- Comment #1 from Christophe Monat  ---
Comment on attachment 39982
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=39982
Proposed patch to fix the regex_iterator constructor

>diff --git a/libstdc++-v3/include/bits/regex.h 
>b/libstdc++-v3/include/bits/regex.h
>index a7d45e6..bb0a167 100644
>--- a/libstdc++-v3/include/bits/regex.h
>+++ b/libstdc++-v3/include/bits/regex.h
>@@ -2454,7 +2454,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11
>* one-past-the-end of a range.
>*/
>   regex_iterator()
>-  : _M_match()
>+  : _M_pregex(), _M_flags(regex_constants::match_default), _M_match()
>   { }
> 
>   /**