http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58087
Bug ID: 58087 Summary: Huge memory consumption with #pragma GCC optimize, __attribute__ and long output paths Product: gcc Version: 4.8.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: translation Assignee: unassigned at gcc dot gnu.org Reporter: manisandro at gmail dot com Using gcc version 4.8.1 20130717 (Red Hat 4.8.1-5) (GCC) Description: Any code containing #pragma GCC optimize, lots of __attribute__(()) will result in cc1 taking up huge amounts of memory _depending_ on the length of the output path. Test case: $ for i in $(seq 1 10000); do echo -e "void __attribute__(()) fz$i();" >> test.h; done $ cat > test.c <<EOF #pragma GCC optimize ("-O1") #include "test.h" int main(){ return 0; } EOF $ wget https://gist.github.com/netj/526585/raw/9044a9972fd71d215ba034a38174960c1c9079ad/memusg $ chmod +x memusg $ mkdir a $ ./memusg gcc -c -o a/test.o test.c memusg: peak=485796 $ mkdir aaaaaaaaaaaaaaaaaaaaaaa $ ./memusg gcc -c -o aaaaaaaaaaaaaaaaaaaaaaa/test.o test.c memusg: peak=4827100 Observations: - The "-O1" is not important, passing any other string to #pragma GCC optimize (regardless of whether it is valid or invalid) will also trigger the issue - As noted, the memory consumption depends on the length of the output path