public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/53650] New: large array causes huge memory use
@ 2012-06-12 23:38 david at doublewise dot net
  2012-06-13  4:59 ` [Bug c++/53650] " hjl.tools at gmail dot com
                   ` (13 more replies)
  0 siblings, 14 replies; 15+ messages in thread
From: david at doublewise dot net @ 2012-06-12 23:38 UTC (permalink / raw)
  To: gcc-bugs

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

             Bug #: 53650
           Summary: large array causes huge memory use
    Classification: Unclassified
           Product: gcc
           Version: 4.7.0
            Status: UNCONFIRMED
          Severity: major
          Priority: P3
         Component: c++
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: david@doublewise.net


This problem did not exist in 4.6.x. The following program uses > 4 GiB of
memory (more than my system has) during compilation. If I reduce the size of
the array a bit, it still uses several GiB but does eventually compile (so the
problem is not infinite recursion) and takes a very long time to compile.
Compiling with optimizations on seems to eliminate the large memory usage but
takes longer than I was willing to wait to compile.

class Class {
public:
    Class() {}
};

int main() {
    Class table [2048][256] = {};
    return 0;
}


Using something like int causes no problems and compiles quickly.

This may also relate to a C++11 missed optimization opportunity, because this
may suggest that the fact that Class has a constructor is making it non-POD,
but the POD rules were relaxed in C++11 to make Class a POD structure (I
think). Compiling with std=c++11 doesn't fix the problem, however.

gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-redhat-linux/4.7.0/lto-wrapper
Target: x86_64-redhat-linux
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man
--infodir=/usr/share/info --with-bugurl=http://bugzilla.redhat.com/bugzilla
--enable-bootstrap --enable-shared --enable-threads=posix
--enable-checking=release --disable-build-with-cxx
--disable-build-poststage1-with-cxx --with-system-zlib --enable-__cxa_atexit
--disable-libunwind-exceptions --enable-gnu-unique-object
--enable-linker-build-id --with-linker-hash-style=gnu
--enable-languages=c,c++,objc,obj-c++,java,fortran,ada,go,lto --enable-plugin
--enable-initfini-array --enable-java-awt=gtk --disable-dssi
--with-java-home=/usr/lib/jvm/java-1.5.0-gcj-1.5.0.0/jre
--enable-libgcj-multifile --enable-java-maintainer-mode
--with-ecj-jar=/usr/share/java/eclipse-ecj.jar --disable-libjava-multilib
--with-ppl --with-cloog --with-tune=generic --with-arch_32=i686
--build=x86_64-redhat-linux
Thread model: posix
gcc version 4.7.0 20120507 (Red Hat 4.7.0-5) (GCC)


^ permalink raw reply	[flat|nested] 15+ messages in thread

* [Bug c++/53650] large array causes huge memory use
  2012-06-12 23:38 [Bug c++/53650] New: large array causes huge memory use david at doublewise dot net
@ 2012-06-13  4:59 ` hjl.tools at gmail dot com
  2012-06-13 18:45 ` [Bug c++/53650] [4.7/4.8 Regression] " david at doublewise dot net
                   ` (12 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: hjl.tools at gmail dot com @ 2012-06-13  4:59 UTC (permalink / raw)
  To: gcc-bugs

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

H.J. Lu <hjl.tools at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2012-06-13
                 CC|                            |jason at redhat dot com
   Target Milestone|---                         |4.7.2
     Ever Confirmed|0                           |1

--- Comment #1 from H.J. Lu <hjl.tools at gmail dot com> 2012-06-13 04:58:35 UTC ---
It is caused by revision 180944:

http://gcc.gnu.org/ml/gcc-cvs/2011-11/msg00230.html


^ permalink raw reply	[flat|nested] 15+ messages in thread

* [Bug c++/53650] [4.7/4.8 Regression] large array causes huge memory use
  2012-06-12 23:38 [Bug c++/53650] New: large array causes huge memory use david at doublewise dot net
  2012-06-13  4:59 ` [Bug c++/53650] " hjl.tools at gmail dot com
@ 2012-06-13 18:45 ` david at doublewise dot net
  2012-06-14  6:19 ` jason at gcc dot gnu.org
                   ` (11 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: david at doublewise dot net @ 2012-06-13 18:45 UTC (permalink / raw)
  To: gcc-bugs

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

David Stone <david at doublewise dot net> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |david at doublewise dot net

--- Comment #2 from David Stone <david at doublewise dot net> 2012-06-13 18:44:18 UTC ---
Turns out that contrary to my previous report, optimizations don't actually
solve the memory use problem, they just slow it down significantly. Several
hours into compilation, memory use was at ~2 GiB and still growing (very
slowly). It seems that maybe it uses just as much memory, it just takes much,
much longer to get there.


^ permalink raw reply	[flat|nested] 15+ messages in thread

* [Bug c++/53650] [4.7/4.8 Regression] large array causes huge memory use
  2012-06-12 23:38 [Bug c++/53650] New: large array causes huge memory use david at doublewise dot net
  2012-06-13  4:59 ` [Bug c++/53650] " hjl.tools at gmail dot com
  2012-06-13 18:45 ` [Bug c++/53650] [4.7/4.8 Regression] " david at doublewise dot net
@ 2012-06-14  6:19 ` jason at gcc dot gnu.org
  2012-06-14  8:38 ` rguenth at gcc dot gnu.org
                   ` (10 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: jason at gcc dot gnu.org @ 2012-06-14  6:19 UTC (permalink / raw)
  To: gcc-bugs

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

Jason Merrill <jason at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jason at gcc dot gnu.org

--- Comment #3 from Jason Merrill <jason at gcc dot gnu.org> 2012-06-14 06:18:41 UTC ---
(In reply to comment #1)
> It is caused by revision 180944:

Specifically, the "Don't use build_aggr_init for aggregate initialization of
arrays." part.


^ permalink raw reply	[flat|nested] 15+ messages in thread

* [Bug c++/53650] [4.7/4.8 Regression] large array causes huge memory use
  2012-06-12 23:38 [Bug c++/53650] New: large array causes huge memory use david at doublewise dot net
                   ` (2 preceding siblings ...)
  2012-06-14  6:19 ` jason at gcc dot gnu.org
@ 2012-06-14  8:38 ` rguenth at gcc dot gnu.org
  2012-06-17 19:55 ` david at doublewise dot net
                   ` (9 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: rguenth at gcc dot gnu.org @ 2012-06-14  8:38 UTC (permalink / raw)
  To: gcc-bugs

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

Richard Guenther <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |slbyan at gmail dot com

--- Comment #4 from Richard Guenther <rguenth at gcc dot gnu.org> 2012-06-14 08:37:34 UTC ---
*** Bug 53666 has been marked as a duplicate of this bug. ***


^ permalink raw reply	[flat|nested] 15+ messages in thread

* [Bug c++/53650] [4.7/4.8 Regression] large array causes huge memory use
  2012-06-12 23:38 [Bug c++/53650] New: large array causes huge memory use david at doublewise dot net
                   ` (3 preceding siblings ...)
  2012-06-14  8:38 ` rguenth at gcc dot gnu.org
@ 2012-06-17 19:55 ` david at doublewise dot net
  2012-06-25 15:59 ` jason at gcc dot gnu.org
                   ` (8 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: david at doublewise dot net @ 2012-06-17 19:55 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #5 from David Stone <david at doublewise dot net> 2012-06-17 19:54:52 UTC ---
As a workaround for this bug, I was able to compile much faster (so that I can
compile my program with optimizations turned on) by declaring the constructor
for the class in the array as constexpr (which worked just fine for me because
I only cared that a single member variable was 0, and the rest could have
indeterminate values).


^ permalink raw reply	[flat|nested] 15+ messages in thread

* [Bug c++/53650] [4.7/4.8 Regression] large array causes huge memory use
  2012-06-12 23:38 [Bug c++/53650] New: large array causes huge memory use david at doublewise dot net
                   ` (4 preceding siblings ...)
  2012-06-17 19:55 ` david at doublewise dot net
@ 2012-06-25 15:59 ` jason at gcc dot gnu.org
  2012-09-06 14:48 ` rguenth at gcc dot gnu.org
                   ` (7 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: jason at gcc dot gnu.org @ 2012-06-25 15:59 UTC (permalink / raw)
  To: gcc-bugs

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

Jason Merrill <jason at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |ASSIGNED
         AssignedTo|unassigned at gcc dot       |jason at gcc dot gnu.org
                   |gnu.org                     |


^ permalink raw reply	[flat|nested] 15+ messages in thread

* [Bug c++/53650] [4.7/4.8 Regression] large array causes huge memory use
  2012-06-12 23:38 [Bug c++/53650] New: large array causes huge memory use david at doublewise dot net
                   ` (5 preceding siblings ...)
  2012-06-25 15:59 ` jason at gcc dot gnu.org
@ 2012-09-06 14:48 ` rguenth at gcc dot gnu.org
  2012-09-20 10:18 ` jakub at gcc dot gnu.org
                   ` (6 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: rguenth at gcc dot gnu.org @ 2012-09-06 14:48 UTC (permalink / raw)
  To: gcc-bugs

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

Richard Guenther <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Priority|P3                          |P2


^ permalink raw reply	[flat|nested] 15+ messages in thread

* [Bug c++/53650] [4.7/4.8 Regression] large array causes huge memory use
  2012-06-12 23:38 [Bug c++/53650] New: large array causes huge memory use david at doublewise dot net
                   ` (6 preceding siblings ...)
  2012-09-06 14:48 ` rguenth at gcc dot gnu.org
@ 2012-09-20 10:18 ` jakub at gcc dot gnu.org
  2013-01-03 16:52 ` jason at gcc dot gnu.org
                   ` (5 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: jakub at gcc dot gnu.org @ 2012-09-20 10:18 UTC (permalink / raw)
  To: gcc-bugs


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

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|4.7.2                       |4.7.3

--- Comment #6 from Jakub Jelinek <jakub at gcc dot gnu.org> 2012-09-20 10:15:58 UTC ---
GCC 4.7.2 has been released.


^ permalink raw reply	[flat|nested] 15+ messages in thread

* [Bug c++/53650] [4.7/4.8 Regression] large array causes huge memory use
  2012-06-12 23:38 [Bug c++/53650] New: large array causes huge memory use david at doublewise dot net
                   ` (7 preceding siblings ...)
  2012-09-20 10:18 ` jakub at gcc dot gnu.org
@ 2013-01-03 16:52 ` jason at gcc dot gnu.org
  2013-01-03 16:54 ` [Bug c++/53650] [4.7 " jason at gcc dot gnu.org
                   ` (4 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: jason at gcc dot gnu.org @ 2013-01-03 16:52 UTC (permalink / raw)
  To: gcc-bugs


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

--- Comment #7 from Jason Merrill <jason at gcc dot gnu.org> 2013-01-03 16:51:51 UTC ---
Author: jason
Date: Thu Jan  3 16:51:41 2013
New Revision: 194860

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=194860
Log:
    PR c++/53650
    * call.c (type_has_extended_temps): New.
    * cp-tree.h: Declare it.
    * decl.c (check_initializer): Use build_aggr_init for arrays
    if it is false.
    * init.c (build_vec_init): Avoid mixed signed/unsigned arithmetic.

Added:
    trunk/gcc/testsuite/g++.dg/init/array34.C
Modified:
    trunk/gcc/cp/ChangeLog
    trunk/gcc/cp/call.c
    trunk/gcc/cp/cp-tree.h
    trunk/gcc/cp/decl.c
    trunk/gcc/cp/init.c


^ permalink raw reply	[flat|nested] 15+ messages in thread

* [Bug c++/53650] [4.7 Regression] large array causes huge memory use
  2012-06-12 23:38 [Bug c++/53650] New: large array causes huge memory use david at doublewise dot net
                   ` (8 preceding siblings ...)
  2013-01-03 16:52 ` jason at gcc dot gnu.org
@ 2013-01-03 16:54 ` jason at gcc dot gnu.org
  2013-01-22 16:29 ` jason at gcc dot gnu.org
                   ` (3 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: jason at gcc dot gnu.org @ 2013-01-03 16:54 UTC (permalink / raw)
  To: gcc-bugs


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

Jason Merrill <jason at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|[4.7/4.8 Regression] large  |[4.7 Regression] large
                   |array causes huge memory    |array causes huge memory
                   |use                         |use

--- Comment #8 from Jason Merrill <jason at gcc dot gnu.org> 2013-01-03 16:53:36 UTC ---
Fixed for 4.8 so far.  Waiting a bit before applying the fix to 4.7.


^ permalink raw reply	[flat|nested] 15+ messages in thread

* [Bug c++/53650] [4.7 Regression] large array causes huge memory use
  2012-06-12 23:38 [Bug c++/53650] New: large array causes huge memory use david at doublewise dot net
                   ` (9 preceding siblings ...)
  2013-01-03 16:54 ` [Bug c++/53650] [4.7 " jason at gcc dot gnu.org
@ 2013-01-22 16:29 ` jason at gcc dot gnu.org
  2013-01-22 16:34 ` jason at gcc dot gnu.org
                   ` (2 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: jason at gcc dot gnu.org @ 2013-01-22 16:29 UTC (permalink / raw)
  To: gcc-bugs


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

--- Comment #9 from Jason Merrill <jason at gcc dot gnu.org> 2013-01-22 16:29:07 UTC ---
Author: jason
Date: Tue Jan 22 16:28:58 2013
New Revision: 195380

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=195380
Log:
    PR c++/53650
    * call.c (type_has_extended_temps): New.
    * cp-tree.h: Declare it.
    * decl.c (check_initializer): Use build_aggr_init for arrays
    if it is false.
    * init.c (build_vec_init): Avoid mixed signed/unsigned arithmetic.

Added:
    branches/gcc-4_7-branch/gcc/testsuite/g++.dg/init/array34.C
Modified:
    branches/gcc-4_7-branch/gcc/cp/ChangeLog
    branches/gcc-4_7-branch/gcc/cp/call.c
    branches/gcc-4_7-branch/gcc/cp/cp-tree.h
    branches/gcc-4_7-branch/gcc/cp/decl.c
    branches/gcc-4_7-branch/gcc/cp/init.c


^ permalink raw reply	[flat|nested] 15+ messages in thread

* [Bug c++/53650] [4.7 Regression] large array causes huge memory use
  2012-06-12 23:38 [Bug c++/53650] New: large array causes huge memory use david at doublewise dot net
                   ` (10 preceding siblings ...)
  2013-01-22 16:29 ` jason at gcc dot gnu.org
@ 2013-01-22 16:34 ` jason at gcc dot gnu.org
  2013-01-22 21:07 ` pluto at agmk dot net
  2013-01-23  2:48 ` jason at gcc dot gnu.org
  13 siblings, 0 replies; 15+ messages in thread
From: jason at gcc dot gnu.org @ 2013-01-22 16:34 UTC (permalink / raw)
  To: gcc-bugs


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

Jason Merrill <jason at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|                            |FIXED

--- Comment #10 from Jason Merrill <jason at gcc dot gnu.org> 2013-01-22 16:34:20 UTC ---
Fixed.


^ permalink raw reply	[flat|nested] 15+ messages in thread

* [Bug c++/53650] [4.7 Regression] large array causes huge memory use
  2012-06-12 23:38 [Bug c++/53650] New: large array causes huge memory use david at doublewise dot net
                   ` (11 preceding siblings ...)
  2013-01-22 16:34 ` jason at gcc dot gnu.org
@ 2013-01-22 21:07 ` pluto at agmk dot net
  2013-01-23  2:48 ` jason at gcc dot gnu.org
  13 siblings, 0 replies; 15+ messages in thread
From: pluto at agmk dot net @ 2013-01-22 21:07 UTC (permalink / raw)
  To: gcc-bugs


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

Pawel Sikora <pluto at agmk dot net> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |pluto at agmk dot net

--- Comment #11 from Pawel Sikora <pluto at agmk dot net> 2013-01-22 21:05:45 UTC ---
(In reply to comment #9)
> Author: jason
> Date: Tue Jan 22 16:28:58 2013
> New Revision: 195380
> 
> URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=195380
> Log:
>     PR c++/53650
>     * call.c (type_has_extended_temps): New.
>     * cp-tree.h: Declare it.
>     * decl.c (check_initializer): Use build_aggr_init for arrays
>     if it is false.
>     * init.c (build_vec_init): Avoid mixed signed/unsigned arithmetic.
> 
> Added:
>     branches/gcc-4_7-branch/gcc/testsuite/g++.dg/init/array34.C
> Modified:
>     branches/gcc-4_7-branch/gcc/cp/ChangeLog
>     branches/gcc-4_7-branch/gcc/cp/call.c
>     branches/gcc-4_7-branch/gcc/cp/cp-tree.h
>     branches/gcc-4_7-branch/gcc/cp/decl.c
>     branches/gcc-4_7-branch/gcc/cp/init.c


this patch breaks bootstrap:

../../gcc/cp/call.c: In function 'type_has_extended_temps':
../../gcc/cp/call.c:8852:7: error: 'for' loop initial declarations are only
allowed in C99 mode
../../gcc/cp/call.c:8852:7: note: use option -std=c99 or -std=gnu99 to compile
your code


^ permalink raw reply	[flat|nested] 15+ messages in thread

* [Bug c++/53650] [4.7 Regression] large array causes huge memory use
  2012-06-12 23:38 [Bug c++/53650] New: large array causes huge memory use david at doublewise dot net
                   ` (12 preceding siblings ...)
  2013-01-22 21:07 ` pluto at agmk dot net
@ 2013-01-23  2:48 ` jason at gcc dot gnu.org
  13 siblings, 0 replies; 15+ messages in thread
From: jason at gcc dot gnu.org @ 2013-01-23  2:48 UTC (permalink / raw)
  To: gcc-bugs


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

--- Comment #12 from Jason Merrill <jason at gcc dot gnu.org> 2013-01-23 02:48:07 UTC ---
Author: jason
Date: Wed Jan 23 02:48:00 2013
New Revision: 195397

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=195397
Log:
    PR c++/53650
    * call.c (type_has_extended_temps): Fix C++ism.

Modified:
    branches/gcc-4_7-branch/gcc/cp/ChangeLog
    branches/gcc-4_7-branch/gcc/cp/call.c


^ permalink raw reply	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2013-01-23  2:48 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-06-12 23:38 [Bug c++/53650] New: large array causes huge memory use david at doublewise dot net
2012-06-13  4:59 ` [Bug c++/53650] " hjl.tools at gmail dot com
2012-06-13 18:45 ` [Bug c++/53650] [4.7/4.8 Regression] " david at doublewise dot net
2012-06-14  6:19 ` jason at gcc dot gnu.org
2012-06-14  8:38 ` rguenth at gcc dot gnu.org
2012-06-17 19:55 ` david at doublewise dot net
2012-06-25 15:59 ` jason at gcc dot gnu.org
2012-09-06 14:48 ` rguenth at gcc dot gnu.org
2012-09-20 10:18 ` jakub at gcc dot gnu.org
2013-01-03 16:52 ` jason at gcc dot gnu.org
2013-01-03 16:54 ` [Bug c++/53650] [4.7 " jason at gcc dot gnu.org
2013-01-22 16:29 ` jason at gcc dot gnu.org
2013-01-22 16:34 ` jason at gcc dot gnu.org
2013-01-22 21:07 ` pluto at agmk dot net
2013-01-23  2:48 ` jason at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).