[Bug preprocessor/17798] New: cpp memory leak with undefined symbols

rth at gcc dot gnu dot org gcc-bugzilla@gcc.gnu.org
Sat Oct 2 22:24:00 GMT 2004


The following generator program

#include <stdio.h>
#include <stdlib.h>                                                            
                   
int main()
{
  int i;
  setvbuf (stdout, malloc(32768), _IOFBF, 32768);                              
                                               
  for (i = 0; i < 10000000; ++i)
    printf ("#ifdef M%d\nchar c%d[] = M%d;\n#endif\n", i, i, i);               
                                                               
  return 0;
}

builds a 483MB file which contains nothing but #ifdefs against undefined
symbols.  The preprocessed file should contain nothing but cpp line notes.

With gcc 3.2, cpp0 has peak memory usage of 930MB.
With gcc 3.4 and 4.0, cc1 has peak memory usage of 2010MB.

While this does strike me as a bit silly, apparently there are users trying
this sort of thing.

  https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=68634

-- 
           Summary: cpp memory leak with undefined symbols
           Product: gcc
           Version: 3.4.3
            Status: UNCONFIRMED
          Keywords: memory-hog
          Severity: normal
          Priority: P2
         Component: preprocessor
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: rth at gcc dot gnu dot org
                CC: gcc-bugs at gcc dot gnu dot org


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=17798



More information about the Gcc-bugs mailing list