Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

no match for ‘operator!=’ in ‘i != std::vector<_Tp, _Alloc>::rend() [with _Tp = re2c::bitmap_t, _Alloc = std::allocator<re2c::bitmap_t>]()’ #198

Closed
ryandesign opened this issue Nov 7, 2017 · 6 comments

Comments

@ryandesign
Copy link
Contributor

@ryandesign ryandesign commented Nov 7, 2017

Hello, I'm a developer with the MacPorts package management system, and I noticed that re2c 1.0.2 does not build on Mac OS X 10.5.8 with its gcc version 4.2.1 (Apple Inc. build 5577). The error is:

depbase=`echo src/code/bitmap.o | sed 's|[^/]*$|.deps/&|;s|\.o$||'`;\
	/usr/bin/g++-4.2 -DHAVE_CONFIG_H -I.   -I/opt/local/include -std=c++98  -W  -Wall  -Wextra  -Weffc++  -pedantic  -Wformat=2  -Wredundant-decls  -Wconversion  -O2  -pipe -Os -arch ppc -MT src/code/bitmap.o -MD -MP -MF $depbase.Tpo -c -o src/code/bitmap.o src/code/bitmap.cc &&\
	mv -f $depbase.Tpo $depbase.Po
In file included from ./src/conf/warn.h:9,
                 from ./src/conf/opt.h:9,
                 from ./src/code/output.h:14,
                 from ./src/code/go.h:8,
                 from src/code/bitmap.cc:5:
./src/util/free_list.h: In instantiation of ‘re2c::free_list<re2c::Code*>’:
./src/re/rule.h:32:   instantiated from here
./src/util/free_list.h:11: warning: base class ‘class std::set<re2c::Code*, std::less<re2c::Code*>, std::allocator<re2c::Code*> >’ has a non-virtual destructor
src/code/bitmap.cc: In member function ‘void re2c::bitmaps_t::insert(const re2c::Go*, const re2c::State*)’:
src/code/bitmap.cc:30: error: no match for ‘operator!=’ in ‘i != std::vector<_Tp, _Alloc>::rend() [with _Tp = re2c::bitmap_t, _Alloc = std::allocator<re2c::bitmap_t>]()’
./src/re/tag.h: At global scope:
./src/re/tag.h:15: warning: ‘re2c::TAGVER_BOTTOM’ defined but not used
./src/re/tag.h:17: warning: ‘re2c::TAGVER_CURSOR’ defined but not used
make[1]: *** [src/code/bitmap.o] Error 1

I am not a C++ programmer so I can't offer any suggestions.

@ryandesign
Copy link
Contributor Author

@ryandesign ryandesign commented Nov 7, 2017

I should add that the above build failure is on a 32-bit PowerPC Mac, Mac OS X 10.5.8, Xcode 3.1.4's gcc version 4.2.1 (Apple Inc. build 5577). The same problem occurs if I use a newer Apple gcc from MacPorts (gcc version 4.2.1 (Apple Inc. build 5666) (dot 3) (MacPorts apple-gcc42 5666.3_15)).

The build succeeds on a 32-bit Intel Mac, Mac OS X 10.6.8, Xcode 3.2.6's gcc version 4.2.1 (Apple Inc. build 5666) (dot 3).

I have also tested gcc version 4.0.1 (Apple Inc. build 5493) on the PowerPC Mac and gcc version 4.0.1 (Apple Inc. build 5494) on the Intel Mac and both fail with:

./src/util/free_list.h: In instantiation of ‘re2c::free_list<re2c::Code*>’:
./src/re/rule.h:32:   instantiated from here
./src/util/free_list.h:11: warning: base class ‘class std::set<re2c::Code*, std::less<re2c::Code*>, std::allocator<re2c::Code*> >’ has a non-virtual destructor
src/code/bitmap.cc: In member function ‘void re2c::bitmaps_t::insert(const re2c::Go*, const re2c::State*)’:
src/code/bitmap.cc:30: error: no match for ‘operator!=’ in ‘i != std::vector<_Tp, _Alloc>::rend() [with _Tp = re2c::bitmap_t, _Alloc = std::allocator<re2c::bitmap_t>]()’
/usr/include/c++/4.0.0/bits/stl_tree.h: In constructor ‘std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::_Rb_tree_impl<_Key_compare, _Is_pod_comparator>::_Rb_tree_impl(const typename _Alloc::rebind<std::_Rb_tree_node<_Val> >::other&, const _Key_compare&) [with _Key_compare = std::less<uint32_t>, bool _Is_pod_comparator = false, _Key = uint32_t, _Val = uint32_t, _KeyOfValue = std::_Identity<uint32_t>, _Compare = std::less<uint32_t>, _Alloc = std::allocator<uint32_t>]’:
/usr/include/c++/4.0.0/bits/stl_tree.h:554:   instantiated from ‘std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::_Rb_tree(const _Compare&, const _Alloc&) [with _Key = uint32_t, _Val = uint32_t, _KeyOfValue = std::_Identity<uint32_t>, _Compare = std::less<uint32_t>, _Alloc = std::allocator<uint32_t>]’
/usr/include/c++/4.0.0/bits/stl_set.h:150:   instantiated from ‘std::set<_Key, _Compare, _Alloc>::set() [with _Key = uint32_t, _Compare = std::less<uint32_t>, _Alloc = std::allocator<uint32_t>]’
./src/re/rule.h:64:   instantiated from here
/usr/include/c++/4.0.0/bits/stl_tree.h:403: warning: ‘std::_Rb_tree<uint32_t, uint32_t, std::_Identity<uint32_t>, std::less<uint32_t>, std::allocator<uint32_t> >::_Rb_tree_impl<std::less<uint32_t>, false>::_M_header’ should be initialized in the member initialization list
make[1]: *** [src/code/bitmap.o] Error 1

Loading

@skvadrik
Copy link
Owner

@skvadrik skvadrik commented Nov 7, 2017

Hi Ryan,

It seems that the problem is caused by an old compiler version that is unable to deduce const-ness of a loop variable in the following (pseudo)code:

for (const_reverse_iterator i = v.rbegin(); i != v.rend(); ++i) ...

Here v.rend() might refer to one of the two overloads:

reverse_iterator rend();
const_reverse_iterator rend() const;

The compiler should deduce the second overload (as the only possible), but for some reason it fails. You can find this issue on stackoverflow: https://stackoverflow.com/questions/5907078/reverse-iterator-error-no-match-for-operator-in-rcit-stdvector-tp

The best option is to update the compiler. If for some reason update is not possible, I can write a patch for re2c-1.0.2 and you would be able to use it in MacPorts. Applying this sort of patches to upstream re2c is a bad thing to do because I have no way of testing if it works, and I will probably "break" the code again very soon.

Loading

@ryandesign
Copy link
Contributor Author

@ryandesign ryandesign commented Nov 7, 2017

Unfortunately, no newer version of Apple gcc exists. gcc 4.3 changed the license to GPL-3, which caused Apple to abandon it and move development to clang, which is a great compiler that we use on newer systems, but it does not work on PowerPC systems. We could probably use a newer FSF gcc on PowerPC systems, at the expense of being able to compile for multiple architectures, since that was a feature Apple added to gcc which is not in FSF gcc. But a compiler is a huge dependency, and re2c is a small program, which is a dependency of ninja, which is a dependency of meson, which is a new build system that we want to use for some programs, and requiring a new compiler just to run what is essentially the equivalent of a configure script seems very heavy to me.

If it's not too difficult to figure out a patch that will let it build with older compilers, that would be appreciated. We can try it in MacPorts before you commit it, but committing it to your sources is best so that all users, not just MacPorts users, can benefit from it.

Loading

skvadrik added a commit that referenced this issue Nov 8, 2017
GCC-4.2.1 is unable to compile code like this:

    std::vector<int> v;
    std::vector<int>::const_reverse_iterator i;
    for (i = v.rbegin(); i != v.rend(); ++i) ;

It's unable to deduce const overload for 'rend':

    "no match for ‘operator!=’ in ‘i != std::vector<_Tp, _Alloc>::rend()"

However, the following code compiles fine:

    std::vector<int> v;
    std::vector<int>::const_reverse_iterator i = v.rbegin(), e = v.rend();
    for (i != e; ++i) ;

This was reported by Ryan Shmidt.
@skvadrik
Copy link
Owner

@skvadrik skvadrik commented Nov 8, 2017

I created a separate branch mac_ports with the necessary fix. Can you check that it works? 5b95c8e

Since it concerns MacOS on PowerPC (and other systems not supported by clang), I will consider merging the fix in master. But the sad thing is, I'll probably break it again in the next release.

Loading

@ryandesign
Copy link
Contributor Author

@ryandesign ryandesign commented Nov 8, 2017

Thanks, I really appreciate your willingness to work on this.

That patch works and I've applied it to MacPorts. If it breaks in the future, I know what to look for and will try to send you fixes.

Loading

@skvadrik
Copy link
Owner

@skvadrik skvadrik commented Nov 8, 2017

Ok! Since the patch is trivial, I've pushed it to master and released 1.0.3.

Loading

@skvadrik skvadrik closed this Oct 21, 2018
ryandesign added a commit to ryandesign/re2c that referenced this issue Jul 4, 2020
Fixes the build for old compilers that can't deduce const overload for
rend.

Similar to previous problem reported in skvadrik#198.
netbsd-srcmastr pushed a commit to NetBSD/pkgsrc that referenced this issue Sep 20, 2020
2.0.3 (2020-08-22)
~~~~~~~~~~~~~~~~~~

- Fix issues when building re2c as a CMake subproject
  (`#302 <https://github.com/skvadrik/re2c/pull/302>`_:

- Final corrections in the SIMPA article "RE2C: A lexer generator based on
  lookahead-TDFA", https://doi.org/10.1016/j.simpa.2020.100027

2.0.2 (2020-08-08)
~~~~~~~~~~~~~~~~~~

- Enable re2go building by default.

- Package CMake files into release tarball.

2.0.1 (2020-07-29)
~~~~~~~~~~~~~~~~~~

- Updated version for CMake build system (forgotten in release 2.0).

- Added a short article about re2c for the Software Impacts journal.

2.0 (2020-07-20)
~~~~~~~~~~~~~~~~

- Added new code generation backend for Go and a new ``re2go`` program
  (`#272 <https://github.com/skvadrik/re2c/issues/272>`_: Go support).
  Added option ``--lang <c | go>``.

- Added CMake build system as an alternative to Autotools
  (`#275 <https://github.com/skvadrik/re2c/pull/275>`_:
  Add a CMake build system (thanks to ligfx),
  `#244 <https://github.com/skvadrik/re2c/issues/244>`_: Switching to CMake).

- Changes in generic API:

  + Removed primitives ``YYSTAGPD`` and ``YYMTAGPD``.
  + Added primitives ``YYSHIFT``, ``YYSHIFTSTAG``, ``YYSHIFTMTAG``
    that allow to express fixed tags in terms of generic API.
  + Added configurations ``re2c:api:style`` and ``re2c:api:sigil``.
  + Added named placeholders in interpolated configuration strings.

- Changes in reuse mode (``-r, --reuse`` option):

  + Do not reset API-related configurations in each `use:re2c` block
    (`#291 <https://github.com/skvadrik/re2c/issues/291>`_:
    Defines in rules block are not propagated to use blocks).
  + Use block-local options instead of last block options.
  + Do not accumulate options from rules/reuse blocks in whole-program options.
  + Generate non-overlapping YYFILL labels for reuse blocks.
  + Generate start label for each reuse block in storable state mode.

- Changes in start-conditions mode (``-c, --start-conditions`` option):

  + Allow to use normal (non-conditional) blocks in `-c` mode
    (`#263 <https://github.com/skvadrik/re2c/issues/263>`_:
    allow mixing conditional and non-conditional blocks with -c,
    `#296 <https://github.com/skvadrik/re2c/issues/296>`_:
    Conditions required for all lexers when using '-c' option).
  + Generate condition switch in every re2c block
    (`#295 <https://github.com/skvadrik/re2c/issues/295>`_:
    Condition switch generated for only one lexer per file).

- Changes in the generated labels:

  + Use ``yyeof`` label prefix instead of ``yyeofrule``.
  + Use ``yyfill`` label prefix instead of ``yyFillLabel``.
  + Decouple start label and initial label (affects label numbering).

- Removed undocumented configuration ``re2c🎏o``, ``re2c🎏output``.

- Changes in ``re2c🎏t``, ``re2c🎏type-header`` configuration:
  filename is now relative to the output file directory.

- Added option ``--case-ranges`` and configuration ``re2c🎏case-ranges``.

- Extended fixed tags optimization for the case of fixed-counter repetition.

- Fixed bugs related to EOF rule:

  + `#276 <https://github.com/skvadrik/re2c/issues/276>`_:
    Example 01_fill.re in docs is broken
  + `#280 <https://github.com/skvadrik/re2c/issues/280>`_:
    EOF rules with multiple blocks
  + `#284 <https://github.com/skvadrik/re2c/issues/284>`_:
    mismatched YYBACKUP and YYRESTORE
    (Add missing fallback states with EOF rule)

- Fixed miscellaneous bugs:

  + `#286 <https://github.com/skvadrik/re2c/issues/286>`_:
    Incorrect submatch values with fixed-length trailing context.
  + `#297 <https://github.com/skvadrik/re2c/issues/297>`_:
    configure error on ubuntu 18.04 / cmake 3.10

- Changed bootstrap process (require explicit configuration flags and a path to
  re2c executable to regenerate the lexers).

- Added internal options ``--posix-prectable <naive | complex>``.

- Added debug option ``--dump-dfa-tree``.

- Major revision of the paper "Efficient POSIX submatch extraction on NFA".

----
1.3x
----

1.3 (2019-12-14)
~~~~~~~~~~~~~~~~

- Added option: ``--stadfa``.

- Added warning: ``-Wsentinel-in-midrule``.

- Added generic API primitives:

  + ``YYSTAGPD``
  + ``YYMTAGPD``

- Added configurations:

  + ``re2c:sentinel = 0;``
  + ``re2c:define:YYSTAGPD = "YYSTAGPD";``
  + ``re2c:define:YYMTAGPD = "YYMTAGPD";``

- Worked on reproducible builds
  (`#258 <https://github.com/skvadrik/re2c/pull/258>`_:
  Make the build reproducible).

----
1.2x
----

1.2.1 (2019-08-11)
~~~~~~~~~~~~~~~~~~

- Fixed bug `#253 <https://github.com/skvadrik/re2c/issues/253>`_:
  re2c should install unicode_categories.re somewhere.

- Fixed bug `#254 <https://github.com/skvadrik/re2c/issues/254>`_:
  Turn off re2c:eof = 0.

1.2 (2019-08-02)
~~~~~~~~~~~~~~~~

- Added EOF rule ``$`` and configuration ``re2c:eof``.

- Added ``/*!include:re2c ... */`` directive and ``-I`` option.

- Added ``/*!header:re2c:on*/`` and ``/*!header:re2c:off*/`` directives.

- Added ``--input-encoding <ascii | utf8>`` option.

  + `#237 <https://github.com/skvadrik/re2c/issues/237>`_:
    Handle non-ASCII encoded characters in regular expressions
  + `#250 <https://github.com/skvadrik/re2c/issues/250>`_
    UTF8 enoding

- Added include file with a list of definitions for Unicode character classes.

  + `#235 <https://github.com/skvadrik/re2c/issues/235>`_:
    Unicode character classes

- Added ``--location-format <gnu | msvc>`` option.

  + `#195 <https://github.com/skvadrik/re2c/issues/195>`_:
    Please consider using Gnu format for error messages

- Added ``--verbose`` option that prints "success" message if re2c exits
  without errors.

- Added configurations for options:

  + ``-o --output`` (specify output file)
  + ``-t --type-header`` (specify header file)

- Removed configurations for internal/debug options.

- Extended ``-r`` option: allow to mix multiple ``/*!rules:re2c*/``,
  ``/*!use:re2c*/`` and ``/*!re2c*/`` blocks.

  + `#55 <https://github.com/skvadrik/re2c/issues/55>`_:
    allow standard re2c blocks in reuse mode

- Fixed ``-F --flex-support`` option: parsing and operator precedence.

  + `#229 <https://github.com/skvadrik/re2c/issues/229>`_:
    re2c option -F (flex syntax) broken
  + `#242 <https://github.com/skvadrik/re2c/issues/242>`_:
    Operator precedence with --flex-syntax is broken

- Changed difference operator ``/`` to apply before encoding expansion of
  operands.

  + `#236 <https://github.com/skvadrik/re2c/issues/236>`_:
    Support range difference with variable-length encodings

- Changed output generation of output file to be atomic.

  + `#245 <https://github.com/skvadrik/re2c/issues/245>`_:
    re2c output is not atomic

- Authored research paper "Efficient POSIX Submatch Extraction on NFA"
  together with Dr Angelo Borsotti.

- Added experimental libre2c library (``--enable-libs`` configure option) with
  the following algorithms:

  + TDFA with leftmost-greedy disambiguation
  + TDFA with POSIX disambiguation (Okui-Suzuki algorithm)
  + TNFA with leftmost-greedy disambiguation
  + TNFA with POSIX disambiguation (Okui-Suzuki algorithm)
  + TNFA with lazy POSIX disambiguation (Okui-Suzuki algorithm)
  + TNFA with POSIX disambiguation (Kuklewicz algorithm)
  + TNFA with POSIX disambiguation (Cox algorithm)

- Added debug subsystem (``--enable-debug`` configure option) and new debug
  options:

  + ``-dump-cfg`` (dump control flow graph of tag variables)
  + ``-dump-interf`` (dump interference table of tag variables)
  + ``-dump-closure-stats`` (dump epsilon-closure statistics)

- Added internal options:

  + ``--posix-closure <gor1 | gtop>`` (switch between shortest-path algorithms
    used for the construction of POSIX closure)

- Fixed a number of crashes found by American Fuzzy Lop fuzzer:

  + `#226 <https://github.com/skvadrik/re2c/issues/226>`_,
    `#227 <https://github.com/skvadrik/re2c/issues/227>`_,
    `#228 <https://github.com/skvadrik/re2c/issues/228>`_,
    `#231 <https://github.com/skvadrik/re2c/issues/231>`_,
    `#232 <https://github.com/skvadrik/re2c/issues/232>`_,
    `#233 <https://github.com/skvadrik/re2c/issues/233>`_,
    `#234 <https://github.com/skvadrik/re2c/issues/234>`_,
    `#238 <https://github.com/skvadrik/re2c/issues/238>`_

- Fixed handling of newlines:

  + correctly parse multi-character newlines CR LF in ``#line`` directives
  + consistently convert all newlines in the generated file to Unix-style LF

- Changed default tarball format from .gz to .xz.

  + `#221 <https://github.com/skvadrik/re2c/issues/221>`_:
    big source tarball

- Fixed a number of other bugs and resolved issues:

  + `#2 <https://github.com/skvadrik/re2c/issues/2>`_: abort
  + `#6 <https://github.com/skvadrik/re2c/issues/6>`_: segfault
  + `#10 <https://github.com/skvadrik/re2c/issues/10>`_:
    lessons/002_upn_calculator/calc_002 doesn't produce a useful example program
  + `#44 <https://github.com/skvadrik/re2c/issues/44>`_:
    Access violation when translating the attached file
  + `#49 <https://github.com/skvadrik/re2c/issues/49>`_:
    wildcard state \000 rules makes lexer behave weard
  + `#98 <https://github.com/skvadrik/re2c/issues/98>`_:
    Transparent handling of #line directives in input files
  + `#104 <https://github.com/skvadrik/re2c/issues/104>`_:
    Improve const-correctness
  + `#105 <https://github.com/skvadrik/re2c/issues/105>`_:
    Conversion of pointer parameters into references
  + `#114 <https://github.com/skvadrik/re2c/issues/114>`_:
    Possibility of fixing bug 2535084
  + `#120 <https://github.com/skvadrik/re2c/issues/120>`_:
    condition consisting of default rule only is ignored
  + `#167 <https://github.com/skvadrik/re2c/issues/167>`_:
    Add word boundary support
  + `#168 <https://github.com/skvadrik/re2c/issues/168>`_:
    Wikipedia's article on re2c
  + `#180 <https://github.com/skvadrik/re2c/issues/180>`_:
    Comment syntax?
  + `#182 <https://github.com/skvadrik/re2c/issues/182>`_:
    yych being set by YYPEEK () and then not used
  + `#196 <https://github.com/skvadrik/re2c/issues/196>`_:
    Implicit type conversion warnings
  + `#198 <https://github.com/skvadrik/re2c/issues/198>`_:
    no match for ‘operator!=’ in ‘i != std::vector<_Tp, _Alloc>::rend() [with _Tp = re2c::bitmap_t, _Alloc = std::allocator<re2c::bitmap_t>]()’
  + `#210 <https://github.com/skvadrik/re2c/issues/210>`_:
    How to build re2c in windows?
  + `#215 <https://github.com/skvadrik/re2c/issues/215>`_:
    A memory read overrun issue in s_to_n32_unsafe.cc
  + `#220 <https://github.com/skvadrik/re2c/issues/220>`_:
    src/dfa/dfa.h: simplify constructor to avoid g++-3.4 bug
  + `#223 <https://github.com/skvadrik/re2c/issues/223>`_:
    Fix typo
  + `#224 <https://github.com/skvadrik/re2c/issues/224>`_:
    src/dfa/closure_posix.cc: pack() tweaks
  + `#225 <https://github.com/skvadrik/re2c/issues/225>`_:
    Documentation link is broken in libre2c/README
  + `#230 <https://github.com/skvadrik/re2c/issues/230>`_:
    Changes for upcoming Travis' infra migration
  + `#239 <https://github.com/skvadrik/re2c/issues/239>`_:
    Push model example has wrong re2c invocation, breaks guide
  + `#241 <https://github.com/skvadrik/re2c/issues/241>`_:
    Guidance on how to use re2c for full-duplex command & response protocol
  + `#243 <https://github.com/skvadrik/re2c/issues/243>`_:
    A code generated for period (.) requires 4 bytes
  + `#246 <https://github.com/skvadrik/re2c/issues/246>`_:
    Please add a license to this repo
  + `#247 <https://github.com/skvadrik/re2c/issues/247>`_:
    Build failure on current Cygwin, probably caused by force-fed c++98 mode
  + `#248 <https://github.com/skvadrik/re2c/issues/248>`_:
    distcheck still looks for README
  + `#251 <https://github.com/skvadrik/re2c/issues/251>`_:
    Including what you use is find, but not without inclusion guards

- Updated documentation and website.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants