public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug other/24472]  New: Invalid global deinitialization order
@ 2005-10-21 10:53 wyderski at ii dot uni dot wroc dot pl
  2005-10-21 12:17 ` [Bug other/24472] " pinskia at gcc dot gnu dot org
  2007-09-20 21:37 ` [Bug target/24472] " dannysmith at users dot sourceforge dot net
  0 siblings, 2 replies; 3+ messages in thread
From: wyderski at ii dot uni dot wroc dot pl @ 2005-10-21 10:53 UTC (permalink / raw)
  To: gcc-bugs

The extension "init_priority" doesn't work correctly on some platforms. Global
static objects are not deinitialized in a proper order, as the following
testcase shows. It is probably because of a linker bug.


----------------------------8<------------------------------

#include <stdio.h>

struct A {

    A() {

        printf("A()\n");
    }

    ~A() {

        printf("~A()\n");
    }
};


struct B {

    B() {

        printf("B()\n");
    }

    ~B() {

        printf("~B()\n");
    }
};


struct C {

    C() {

        printf("C()\n");
    }

    ~C() {

        printf("~C()\n");
    }
};

struct D {

    D() {

        printf("D()\n");
    }

    ~D() {

        printf("~D()\n");
    }
};

static A a;
static B b;
static C c __attribute__((init_priority(101)));
static D d;

int main(int argc, char *argv[])
{

 return 0;
}

----------------------------8<------------------------------

It produces:

C() <= this is OK because of init_priority
A()
B()
D()
~C() <= deinitialization order error
~D()
~B()
~A()

But it should be:

C()
A()
B()
D()
~D()
~B()
~A()
~C() <= should be deinitialized here


-- 
           Summary: Invalid global deinitialization order
           Product: gcc
           Version: 4.0.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: other
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: wyderski at ii dot uni dot wroc dot pl
  GCC host triplet: IA-32, GCC 4.0.0 (DJGPP package), Windows XP


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


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

* [Bug other/24472] Invalid global deinitialization order
  2005-10-21 10:53 [Bug other/24472] New: Invalid global deinitialization order wyderski at ii dot uni dot wroc dot pl
@ 2005-10-21 12:17 ` pinskia at gcc dot gnu dot org
  2007-09-20 21:37 ` [Bug target/24472] " dannysmith at users dot sourceforge dot net
  1 sibling, 0 replies; 3+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-10-21 12:17 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from pinskia at gcc dot gnu dot org  2005-10-21 12:17 -------
*** Bug 24471 has been marked as a duplicate of this bug. ***


-- 


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


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

* [Bug target/24472] Invalid global deinitialization order
  2005-10-21 10:53 [Bug other/24472] New: Invalid global deinitialization order wyderski at ii dot uni dot wroc dot pl
  2005-10-21 12:17 ` [Bug other/24472] " pinskia at gcc dot gnu dot org
@ 2007-09-20 21:37 ` dannysmith at users dot sourceforge dot net
  1 sibling, 0 replies; 3+ messages in thread
From: dannysmith at users dot sourceforge dot net @ 2007-09-20 21:37 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from dannysmith at users dot sourceforge dot net  2007-09-20 21:36 -------
This is fixed on trunk  by  TARGET_CXX_USE_ATEXIT_FOR_CXA_ATEXIT patch
http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=118371

Danny


-- 

dannysmith at users dot sourceforge dot net changed:

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


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


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

end of thread, other threads:[~2007-09-20 21:37 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-10-21 10:53 [Bug other/24472] New: Invalid global deinitialization order wyderski at ii dot uni dot wroc dot pl
2005-10-21 12:17 ` [Bug other/24472] " pinskia at gcc dot gnu dot org
2007-09-20 21:37 ` [Bug target/24472] " dannysmith at users dot sourceforge dot net

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).