public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
* c++/2320: incorrect order of destruction of function parameters
@ 2001-03-19  9:16 James.Kanze
  0 siblings, 0 replies; 2+ messages in thread
From: James.Kanze @ 2001-03-19  9:16 UTC (permalink / raw)
  To: gcc-gnats

>Number:         2320
>Category:       c++
>Synopsis:       incorrect order of destruction of function parameters
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    unassigned
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Mon Mar 19 09:16:01 PST 2001
>Closed-Date:
>Last-Modified:
>Originator:     James Kanze
>Release:        gcc version 2.95.2 19991024
>Organization:
>Environment:
Windows 2000, CygWin 1.1.8
>Description:
According to ISO 14882:1998, paragraph 6.6/2: "On exit from scope
(however accomplished), destructors are called for all constructed
objects with automatic storage duration (named objects or temporaries)
that are declared in that scope, in the REVERSE order of their
declaration."  You will note that the objects 3 and 4, above, are
destructed in the order of their declaration, not the reverse order.
>How-To-Repeat:
Compile function with:
    g++ --verbose orderdtors.cc -o order
Then execute program with
    order
Output is
A::A(): 1
B::B(): 2
A::A(A): 3
B::B(B): 4
A::~A(): 3
B::~B(): 4
B::~B(): 2
A::~A(): 1

The fourth and fifth lines should be inverted.
>Fix:

>Release-Note:
>Audit-Trail:
>Unformatted:
----gnatsweb-attachment----
Content-Type: application/octet-stream; name="orderdtors.cc"
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename="orderdtors.cc"

DQojaW5jbHVkZSA8aW9zdHJlYW0uaD4NCg0KaW50IGluc3RhbmNlQ291bnQgPSAwIDsNCg0KY2xh
c3MgQSB7DQpwdWJsaWM6DQogICAgQSgpIDsNCiAgICBBKCBBIGNvbnN0JiApIDsNCiAgICB+QSgp
IDsNCnByaXZhdGU6DQogICAgaW50IGluc3RhbmNlIDsNCn0gOw0KDQpBOjpBKCkgOiBpbnN0YW5j
ZSggKytpbnN0YW5jZUNvdW50ICkgDQogICAgeyBjb3V0IDw8ICJBOjpBKCk6ICIgPDwgaW5zdGFu
Y2UgPDwgZW5kbCA7IH0NCkE6OkEoIEEgY29uc3QmICk6IGluc3RhbmNlKCArK2luc3RhbmNlQ291
bnQgKSAgDQogICAgeyBjb3V0IDw8ICJBOjpBKEEpOiAiIDw8IGluc3RhbmNlIDw8IGVuZGwgOyB9
DQpBOjp+QSgpIHsgY291dCA8PCAiQTo6fkEoKTogIiA8PCBpbnN0YW5jZSA8PCBlbmRsIDsgfQ0K
DQpjbGFzcyBCIHsNCnB1YmxpYzoNCiAgICBCKCkgOw0KICAgIEIoIEIgY29uc3QmICkgOw0KICAg
IH5CKCkgOw0KcHJpdmF0ZToNCiAgICBpbnQgaW5zdGFuY2UgOw0KfSA7DQoNCkI6OkIoKSA6IGlu
c3RhbmNlKCArK2luc3RhbmNlQ291bnQgKSANCiAgICB7IGNvdXQgPDwgIkI6OkIoKTogIiA8PCBp
bnN0YW5jZSA8PCBlbmRsIDsgfQ0KQjo6QiggQiBjb25zdCYgKTogaW5zdGFuY2UoICsraW5zdGFu
Y2VDb3VudCApICANCiAgICB7IGNvdXQgPDwgIkI6OkIoQik6ICIgPDwgaW5zdGFuY2UgPDwgZW5k
bCA7IH0NCkI6On5CKCkgeyBjb3V0IDw8ICJCOjp+QigpOiAiIDw8IGluc3RhbmNlIDw8IGVuZGwg
OyB9DQoNCg0Kdm9pZA0KZiggQSBhICwgQiBiICkNCnsNCn0NCg0KaW50DQptYWluKCkNCnsNCiAg
ICBBIGFuQSA7DQogICAgQiBhQiA7DQogICAgZiggYW5BICwgYUIgKSA7DQogICAgcmV0dXJuIDAg
Ow0KfQ0K


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

* Re: c++/2320: incorrect order of destruction of function parameters
@ 2001-03-19 11:06 Gabriel Dos Reis
  0 siblings, 0 replies; 2+ messages in thread
From: Gabriel Dos Reis @ 2001-03-19 11:06 UTC (permalink / raw)
  To: nobody; +Cc: gcc-prs

The following reply was made to PR c++/2320; it has been noted by GNATS.

From: Gabriel Dos Reis <gdr@codesourcery.com>
To: James.Kanze@dresdner-bank.com
Cc: gcc-gnats@gcc.gnu.org
Subject: Re: c++/2320: incorrect order of destruction of function parameters
Date: 19 Mar 2001 19:56:07 +0100

 James.Kanze@dresdner-bank.com writes:
 
 [...]
 
 | According to ISO 14882:1998, paragraph 6.6/2: "On exit from scope
 | (however accomplished), destructors are called for all constructed
 | objects with automatic storage duration (named objects or temporaries)
 | that are declared in that scope, in the REVERSE order of their
 | declaration."  You will note that the objects 3 and 4, above, are
 | destructed in the order of their declaration, not the reverse order.
 | >How-To-Repeat:
 | Compile function with:
 |     g++ --verbose orderdtors.cc -o order
 | Then execute program with
 |     order
 | Output is
 | A::A(): 1
 | B::B(): 2
 | A::A(A): 3
 | B::B(B): 4
 | A::~A(): 3
 | B::~B(): 4
 | B::~B(): 2
 | A::~A(): 1
 
 Hi,
 
 I can confirm the bug you're reporting in gcc-2.95.2.
 
 However "gcc version 3.0 20010314 (prerelease)" gives the correct
 behavior
 
 A::A(): 1
 B::B(): 2
 A::A(A): 3
 B::B(B): 4
 B::~B(): 4
 A::~A(): 3
 B::~B(): 2
 A::~A(): 1
 
 
 -- Gaby
 CodeSourcery, LLC                       http://www.codesourcery.com


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

end of thread, other threads:[~2001-03-19 11:06 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-03-19  9:16 c++/2320: incorrect order of destruction of function parameters James.Kanze
2001-03-19 11:06 Gabriel Dos Reis

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