public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/16269] New: g++ doesn't reuse stack space
@ 2004-06-29 14:49 mrs at apple dot com
  2004-06-29 15:08 ` [Bug c++/16269] " pinskia at gcc dot gnu dot org
                   ` (3 more replies)
  0 siblings, 4 replies; 7+ messages in thread
From: mrs at apple dot com @ 2004-06-29 14:49 UTC (permalink / raw)
  To: gcc-bugs

There used to be a test case in dejagnu that tested for g++'s ability to reuse stack space.  That 
testcase was g++.old-deja/g++.mike/p7325.C:

// { dg-do run { xfail *-*-* } }
// I hate this type of test case.  I'm not sure how to code it better.
// See the PR for what this tests.
// prms-id: 7325

int fail = 0;

struct A {
  int i;
  static const A* match_this;
  static const A* match_arg;
  A(): i(7) {
    if (match_this)
      if (match_this != this)
        fail = 1;
  }
  A* get_this() { return this; }
  A& operator = (const A& o) {
    if (match_this)
      if (match_this != this)
        fail = 1;
    if (match_arg)
      if (match_arg != &o)
        fail = 1;
    match_arg = &o;
    return *this;
  }
};

const A* A::match_this;
const A* A::match_arg;
A a;

A foo() { return a; }
void f ()
{
  A a;
  A::match_this = &a;
  a = foo ();
  a = foo ();
  A::match_this = 0;
}

void g ()
{
  A::match_this = A().get_this();
  A();
  A();
  A::match_this = 0;
}

int main() {
  f();
  g();
  return fail;
}

This used to pass, but someone broke it.  Redhat's devo should be able to tell us when it passed 
by checking the add time of the testcase.  A search should tell us who broke it and when.

More state can be found in 7325 in Redhat's old bug database.

I'm reporting this, as that testcase, likely the only one of its type was recently removed from the 
testsuite, and the failure visibility that the test case brough, gone.

-- 
           Summary: g++ doesn't reuse stack space
           Product: gcc
           Version: 3.5.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: mrs at apple dot com
                CC: gcc-bugs at gcc dot gnu dot org
 GCC build triplet: powerpc-apple-darwin6.3
  GCC host triplet: powerpc-apple-darwin6.3
GCC target triplet: powerpc-apple-darwin6.3


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


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

* [Bug c++/16269] g++ doesn't reuse stack space
  2004-06-29 14:49 [Bug c++/16269] New: g++ doesn't reuse stack space mrs at apple dot com
@ 2004-06-29 15:08 ` pinskia at gcc dot gnu dot org
  2004-07-10  2:50 ` giovannibajo at libero dot it
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 7+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-06-29 15:08 UTC (permalink / raw)
  To: gcc-bugs



-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |missed-optimization


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


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

* [Bug c++/16269] g++ doesn't reuse stack space
  2004-06-29 14:49 [Bug c++/16269] New: g++ doesn't reuse stack space mrs at apple dot com
  2004-06-29 15:08 ` [Bug c++/16269] " pinskia at gcc dot gnu dot org
@ 2004-07-10  2:50 ` giovannibajo at libero dot it
  2004-09-03 23:52 ` rth at gcc dot gnu dot org
  2004-09-04  0:06 ` rth at gcc dot gnu dot org
  3 siblings, 0 replies; 7+ messages in thread
From: giovannibajo at libero dot it @ 2004-07-10  2:50 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From giovannibajo at libero dot it  2004-07-10 02:50 -------
Confirmed, and surely related to PR 9997.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
  BugsThisDependsOn|                            |9997
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|                            |1
   Last reconfirmed|0000-00-00 00:00:00         |2004-07-10 02:50:38
               date|                            |


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


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

* [Bug c++/16269] g++ doesn't reuse stack space
  2004-06-29 14:49 [Bug c++/16269] New: g++ doesn't reuse stack space mrs at apple dot com
  2004-06-29 15:08 ` [Bug c++/16269] " pinskia at gcc dot gnu dot org
  2004-07-10  2:50 ` giovannibajo at libero dot it
@ 2004-09-03 23:52 ` rth at gcc dot gnu dot org
  2004-09-04  0:06 ` rth at gcc dot gnu dot org
  3 siblings, 0 replies; 7+ messages in thread
From: rth at gcc dot gnu dot org @ 2004-09-03 23:52 UTC (permalink / raw)
  To: gcc-bugs



-- 
Bug 16269 depends on bug 9997, which changed state.

Bug 9997 Summary: Coelesce stack slots for disjoint scopes.
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=9997

           What    |Old Value                   |New Value
----------------------------------------------------------------------------
             Status|NEW                         |ASSIGNED
             Status|ASSIGNED                    |RESOLVED
         Resolution|                            |FIXED

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


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

* [Bug c++/16269] g++ doesn't reuse stack space
  2004-06-29 14:49 [Bug c++/16269] New: g++ doesn't reuse stack space mrs at apple dot com
                   ` (2 preceding siblings ...)
  2004-09-03 23:52 ` rth at gcc dot gnu dot org
@ 2004-09-04  0:06 ` rth at gcc dot gnu dot org
  3 siblings, 0 replies; 7+ messages in thread
From: rth at gcc dot gnu dot org @ 2004-09-04  0:06 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From rth at gcc dot gnu dot org  2004-09-04 00:06 -------
No, not related to 9997.  In this case we have 

  struct A <D1614>;
  struct A <D1615>;
  ...                                                                              
  <D1614> = foo ();
  operator= (&a, &<D1614>);
  <D1615> = foo ();
  operator= (&a, &<D1615>);

These two compiler temporaries are in the same scope, and thus the code that
lays out stack space will not be given an opportunity to share the memory.
In order for this to work as you expect, the front end would have to be 
changed to generate

  {
    struct A <D1614>;
    <D1614> = foo ();
    operator= (&a, &<D1614>);
  }
  {
    struct A <D1615>;
    <D1615> = foo ();
    operator= (&a, &<D1615>);
  }

In other words, be more explicit about the lifetimes of the temporaries
that it creates.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
   Last reconfirmed|2004-07-10 02:50:38         |2004-09-04 00:06:38
               date|                            |


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


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

* [Bug c++/16269] g++ doesn't reuse stack space
       [not found] <bug-16269-1447@http.gcc.gnu.org/bugzilla/>
  2006-09-06 20:56 ` jason at gcc dot gnu dot org
@ 2009-04-22 21:12 ` pinskia at gcc dot gnu dot org
  1 sibling, 0 replies; 7+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2009-04-22 21:12 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #4 from pinskia at gcc dot gnu dot org  2009-04-22 21:12 -------
This has been fixed for awhile now, since at least 4.3.0.


-- 

pinskia at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED
   Target Milestone|---                         |4.3.0


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


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

* [Bug c++/16269] g++ doesn't reuse stack space
       [not found] <bug-16269-1447@http.gcc.gnu.org/bugzilla/>
@ 2006-09-06 20:56 ` jason at gcc dot gnu dot org
  2009-04-22 21:12 ` pinskia at gcc dot gnu dot org
  1 sibling, 0 replies; 7+ messages in thread
From: jason at gcc dot gnu dot org @ 2006-09-06 20:56 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from jason at gcc dot gnu dot org  2006-09-06 20:56 -------
This isn't only a problem in C++.  In this C testcase:

struct A
{
  int i[42];
};

struct A f();

int main()
{
  f();
  f();
  f();
}

we allocate 3 'struct A' temporaries.


-- 

jason at gcc dot gnu dot org changed:

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


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


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

end of thread, other threads:[~2009-04-22 21:12 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-06-29 14:49 [Bug c++/16269] New: g++ doesn't reuse stack space mrs at apple dot com
2004-06-29 15:08 ` [Bug c++/16269] " pinskia at gcc dot gnu dot org
2004-07-10  2:50 ` giovannibajo at libero dot it
2004-09-03 23:52 ` rth at gcc dot gnu dot org
2004-09-04  0:06 ` rth at gcc dot gnu dot org
     [not found] <bug-16269-1447@http.gcc.gnu.org/bugzilla/>
2006-09-06 20:56 ` jason at gcc dot gnu dot org
2009-04-22 21:12 ` pinskia at gcc dot gnu dot 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).