GNOME Bugzilla – Bug 720100
parse: redefinition of malloc - old grammar.y bugs crawl out of the woodwork
Last modified: 2013-12-27 11:56:06 UTC
bug 712679 added back the -Werror flag, and now gcc dies on warnings. Luckily, there's only one source of warnings in grammar.y: grammar.tab.c:924:7: error: redundant redeclaration of 'malloc' [-Werror=redundant-decls] # define YYMALLOC malloc ^ grammar.tab.c:931:6: error: redundant redeclaration of 'free' [-Werror=redundant-decls] # define YYFREE free ^ Note that line numbers make no sense. The lines that ARE triggering this: void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */ and void free (void *); /* INFRINGES ON USER NAME SPACE */ These lines are added in a nest of preprocessor commands. Sadly, preprocessor checks for _STDLIB_H to detect stdlib.h, not _STDLIB_H_ (mingw.org) or _INC_STDLIB (mingw-w64). Thus the code (generated by flex, so we can't really fix the check itself) thinks that stdlib.h was not included, and decides to just add prototypes for malloc() and free() (there's a part where it includes stdlib.h and defines _STDLIB_H by itself, but it's C++-only). How to fix: Add this to grammar.y after including stdlib.h: #ifndef _STDLIB_H # define _STDLIB_H 1 #endif
commit c3181fa5df967cc67f3323b20c3cc2f71aff4b03 Author: Sebastian Dröge <sebastian@centricular.com> Date: Fri Dec 27 12:55:02 2013 +0100 parse: Use GLib malloc/free/realloc functions https://bugzilla.gnome.org/show_bug.cgi?id=720100