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

            Bug ID: 96382
           Summary: const_reverse_iterator() ctor is rejected in c++98
           Product: gcc
           Version: 10.1.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libstdc++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: slyfox at gcc dot gnu.org
                CC: jwakely at redhat dot com
  Target Milestone: ---

Original build failure is found on re2c-2.0 project. Minimal failing example:

$ cat a.cc
#include <vector>

// g++-10.2.0 -c a.cc -std=c++98:
//   ok
//
// g++-11.0.0 -c a.cc -std=c++98:
//   ': current(__x.current) { } is protected within this context'

bool f(void) {
    std::vector<int> v;
    std::vector<int>::const_reverse_iterator ri = v.rbegin();
    return ri != v.rend();
}

$ LANG=C g++-11.0.0 -c a.cc -std=c++98
In file included from
/usr/lib/gcc/x86_64-pc-linux-gnu/11.0.0/include/g++-v11/bits/stl_algobase.h:67,
                 from
/usr/lib/gcc/x86_64-pc-linux-gnu/11.0.0/include/g++-v11/vector:60,
                 from a.cc:1:
/usr/lib/gcc/x86_64-pc-linux-gnu/11.0.0/include/g++-v11/bits/stl_iterator.h: In
instantiation of 'std::reverse_iterator<_Iterator>::reverse_iterator(const
std::reverse_iterator<_Iter>&) [with _Iter = __gnu_cxx::__normal_iterator<int*,
std::vector<int> >; _Iterator = __gnu_cxx::__normal_iterator<const int*,
std::vector<int> >]':
a.cc:11:60:   required from here
/usr/lib/gcc/x86_64-pc-linux-gnu/11.0.0/include/g++-v11/bits/stl_iterator.h:203:23:
error: '__gnu_cxx::__normal_iterator<int*, std::vector<int> >
std::reverse_iterator<__gnu_cxx::__normal_iterator<int*, std::vector<int> >
>::current' is protected within this context
  203 |         : current(__x.current) { }
      |                   ~~~~^~~~~~~
/usr/lib/gcc/x86_64-pc-linux-gnu/11.0.0/include/g++-v11/bits/stl_iterator.h:146:17:
note: declared protected here
  146 |       _Iterator current;
      |                 ^~~~~~~
$ LANG=C g++-10.2.0 -c a.cc -std=c++98

Probably started at
https://gcc.gnu.org/git/?p=gcc.git;a=commitdiff;h=a5a8a4e61565a2a66391e29eb80813c581b7dc52

Reply via email to