This is the mail archive of the mailing list for the GCC project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: (f)lex & poisoned malloc / free in system.h

 > From: Michael Meeks <>
 > Hi Kaveh,
 > > Barring that if flex defines some magic macro (FLEX_SCANNER?) then we
 > > could bypass the poison in system.h when it sees that defined.
 >         Yes, indeed - this would work well for flex, does a gcc
 > compilation mandate flex ?

This is new territory since there's no bundled gcc code using {f}lex
as of today.  For new frontends we'll have to establish something.

I know e.g. that we require bison, and do not support yacc.  So by
analogy we should say flex is required and lex isn't supported.  This
has practical benefits in that we don't have to worry about receiving
problem reports due to buggy proprietary lex implementations.

Assuming that is acceptable, does the following patch solve the
problem for you?


2001-05-04  Kaveh R. Ghazi  <>

	* system.h: Don't poison memory allocation tokens if compiling
	a flex scanner.

--- orig/egcs-CVS20010503/gcc/system.h	Thu Apr 12 11:36:24 2001
+++ egcs-CVS20010503/gcc/system.h	Fri May  4 11:50:01 2001
@@ -538,8 +538,9 @@ typedef char _Bool;
 /* Note autoconf checks for prototype declarations and includes
    system.h while doing so.  Only poison these tokens if actually
    compiling gcc, so that the autoconf declaration tests for malloc
-   etc don't spuriously fail.  */
-#ifdef IN_GCC
+   etc don't spuriously fail.  Don't poison these tokens if we're
+   compiling a flex scanner since they might include calls to malloc.  */
+#if defined (IN_GCC) && ! defined (FLEX_SCANNER)
 #undef malloc
 #undef realloc
 #undef calloc

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]