Skip to content

error: ‘reverse’ is not a member of ‘std’ #377

Closed

Description

@hangingman

On C++ backend, generated codes should add #include <algorithm>

This is my output logs during building bnfc generated C++ code

make
g++ -g --ansi -W -Wall -Wno-unused-parameter -Wno-unused-function -Wno-unneeded-internal-declaration -c Absyn.C
g++ -g --ansi -W -Wall -Wno-unused-parameter -Wno-unused-function -Wno-unneeded-internal-declaration -c Parser.C
Nask.y: In function ‘int nask_parse(yyscan_t, YYSTYPE*)’:
Nask.y:440:27: error: ‘reverse’ is not a member of ‘std’
  440 | Program : ListStmt { std::reverse($1->begin(),$1->end()) ;$$ = new Prog($1); result->program_ = $$; }

Activity

  1. andreasabel commented on Aug 26, 2021

    @andreasabel
    Member

    Apple clang version 11.0.0 (clang-1100.0.33.17) does not need this, but clang isn't always faithful to the standard.

    Which version of g++ do you have? What does g++ --version print?

  2. andreasabel commented on Aug 26, 2021

    @andreasabel
    Member

    I can reproduce the problem with c++-11 (Homebrew GCC 11.2.0) 11.2.0.

  3. andreasabel commented on Aug 26, 2021

    @andreasabel
    Member

    On C++ backend, generated codes should add #include <algorithm>

    This was the case until BNFC-2.9.1, so it is a regression I introduced when unifying the bison backends.

  4. self-assigned this
    on Aug 26, 2021
  5. added this to the 2.9.3 milestone on Aug 26, 2021
  6. hangingman commented on Aug 27, 2021

    @hangingman
    Author

    @andreasabel Great, thank you !

  7. hangingman commented on Aug 27, 2021

    @hangingman
    Author

    FYI my g++ version

    $ g++ --version
    g++ (Debian 10.2.1-6) 10.2.1 20210110
    Copyright (C) 2020 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.
    
  8. added a commit that references this issue on Mar 1, 2026
    c66cb34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

C++parserIssues concerning parser generatingregression in 2.9.2Regression that first appeared in BNFC 2.9.2

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions