GCC Bugzilla – Attachment 18927 Details for
Bug 41858
-flto -O2 crashes when many source files.
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
a small program which generates many files to exhibit the bug
main.c (text/x-csrc), 2.50 KB, created by
Basile Starynkevitch
on 2009-10-28 21:40:35 UTC
(
hide
)
Description:
a small program which generates many files to exhibit the bug
Filename:
MIME Type:
Creator:
Basile Starynkevitch
Created:
2009-10-28 21:40:35 UTC
Size:
2.50 KB
patch
obsolete
>/* file main.c */ >#include <stdio.h> >#include <stdlib.h> >#include <string.h> >#include <errno.h> >/* the first time this program, compiled with gcc main.c -o main is > run, it creates many small C files [A-Z]*.c; the second time it is > run, it should be compiled with: gcc -DGENERATEDALL main.c [A-Z]*.c -o big > */ > >/* make a readable name like D_23 */ >void >name_fun (char *buf, size_t siz, int i) >{ > if (i < 0) > i = 0; > snprintf (buf, siz, "%c_%d", 'A' + (i % 26), i / 26); >} > >int >main (int argc, char **argv) >{ > int cnt = 3000; > char funam[40]; > char callednam[40]; > char filnam[48]; > int i = 0; > memset (funam, 0, sizeof (funam)); > memset (callednam, 0, sizeof (callednam)); > memset (filnam, 0, sizeof (filnam)); > if (argc > 1) > cnt = atoi (argv[1]); > if (cnt <= 8) > cnt = 8; >#ifndef GENERATEDALL > /* generate all the files */ > for (i=0; i <= cnt; i++) > { > FILE *f = 0; > int k = 0; > memset (funam, 0, sizeof (funam)); > memset (callednam, 0, sizeof (callednam)); > memset (filnam, 0, sizeof (filnam)); > name_fun (funam, sizeof (funam), i); > snprintf (filnam, sizeof (filnam) - 1, "%s.c", funam); > f = fopen (filnam, "w"); > if (!f) > { > fprintf (stderr, "failed to open %s - %s\n", filnam, > strerror (errno)); > exit (1); > } > fprintf (f, "/* generated file %s */\n", filnam); > fputs ("#include <stdio.h>\n", f); > fprintf (f, "void %s(int x) {", funam); > fputs (" printf(\"in %s x=%d\\n\", __FUNCTION__, x);\n", f); > for (k = 0; k < 10 + cnt / 40; k++) > { > int dice = 0; > if (i > 10) > dice = lrand48 () % (i / 2 + 3); > else > dice = i / 3; > fprintf (f, " if (x > %d)\n", (int) (6 + lrand48 () % (3 + cnt / 2))); > if (dice <= 0) > fputs (" printf(\"..x=%d\\n\", x--);\n", f); > else > { > name_fun (callednam, sizeof (callednam), dice); > fprintf (f, " %s (x- x/4);\n", callednam); > } > } > fputs (" printf(\"done %s x=%d\\n\", __FUNCTION__, x);\n", f); > fprintf (f, "} /* end %s */\n", funam); > if (i == cnt) > fprintf (f, "void last(int n) { %s (n); }\n", funam); > fclose (f); > f = NULL; > if (i % 64 == 0) > printf ("generated function #%d in %s\n", i, funam); > }; > printf ("generated %d files last is %s\n", cnt, filnam); > printf ("try to compile all %d files with:\n" > "\t gcc-trunk -flto -O2 -DGENERATEDALL main.c [A-Z]*.c -o big\n", > cnt); >#else > printf ("calling the last function with %d\n", cnt); > last (cnt); > printf ("thanks for all the fish\n"); >#endif > return 0; >}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 41858
: 18927