Skip to content

Compilation error of bison generated code with gcc11 #232

@d-otte

Description

@d-otte

Symptom

Invoking make all generates the following error message (using gcc11, which is the default gcc in ubuntu 21.10):

[...]
Compiling erpcgen/src/options.cpp
Compiling erpcgen/src/types/Type.cpp
<build-dir>/erpc/Debug/Linux/erpcgen/obj/erpcgen_parser.tab.cpp: In function 'int yyparse(erpcgen::ErpcLexer*, erpcgen::AstNode**)':
<build-dir>/erpc/Debug/Linux/erpcgen/obj/erpcgen_parser.tab.cpp:3810:18: error: 'void free(void*)' called on unallocated object 'yyssa' [-Werror=free-nonheap-object]
 3810 |     YYSTACK_FREE (yyss);
<build-dir>/erpc/Debug/Linux/erpcgen/obj/erpcgen_parser.tab.cpp:2025:16: note: declared here
 2025 |     yy_state_t yyssa[YYINITDEPTH];
      |                ^~~~~
At global scope:
cc1plus: note: unrecognized command-line option '-Wno-deprecated-register' may have been intended to silence earlier diagnostics
cc1plus: all warnings being treated as errors
make[1]: *** [<build-dir>/erpc/mk/targets.mk:97: <build-dir>/erpc/Debug/Linux/erpcgen/obj/Debug/Linux/erpcgen/obj/erpcgen_parser.tab.o] Error 1
make[1]: *** Waiting for unfinished jobs....
make: *** [<build-dir>/erpc/mk/subdirs.mk:42: erpcgen] Error 2

Cause

  1. invoking gcc11 with -O0 causes a false warning for freeing a non heap object.
  2. invoking gcc with the -Werror flag causes the warning to become an error.

Code generated with bison is known to cause this issue (https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98753).

Workaround

Invoking make with CXXFLAGS=-Wno-error=free-nonheap-object turns this specific error back into a warning.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions