This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
c++/7430: if method signature lies "I return SomeClass by value" but actually there is no 'return' then construct-destruct asymmetry results!
- From: dh at digitalbrain dot com
- To: gcc-gnats at gcc dot gnu dot org
- Date: 29 Jul 2002 10:57:21 -0000
- Subject: c++/7430: if method signature lies "I return SomeClass by value" but actually there is no 'return' then construct-destruct asymmetry results!
- Reply-to: dh at digitalbrain dot com
>Number: 7430
>Category: c++
>Synopsis: if method signature lies "I return SomeClass by value" but actually there is no 'return' then construct-destruct asymmetry results!
>Confidential: no
>Severity: non-critical
>Priority: medium
>Responsible: unassigned
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Mon Jul 29 04:06:01 PDT 2002
>Closed-Date:
>Last-Modified:
>Originator: dh@digitalbrain.com
>Release: unknown-1.0
>Organization:
>Environment:
// BUG IN THIS VERSION OF GCC:
// Reading specs from /usr/lib/gcc-lib/i386-linux/2.95.4/specs
// gcc version 2.95.4 20011002 (Debian prerelease)
// RUNNING UNDER:
// Linux fee 2.4.18 #1 SMP Tue May 21 10:16:05 BST 2002 i686 unknown
>Description:
see How-To-Repeat
>How-To-Repeat:
try this prog:
// BUG IN THIS VERSION OF GCC:
// Reading specs from /usr/lib/gcc-lib/i386-linux/2.95.4/specs
// gcc version 2.95.4 20011002 (Debian prerelease)
// RUNNING UNDER:
// Linux fee 2.4.18 #1 SMP Tue May 21 10:16:05 BST 2002 i686 unknown
struct X {
char* m_;
X() : m_(new char[5]) {}
~X() { delete[] m_; }
};
struct C {
X MightReturnCheese() {
//
// INSTRUCTIONS:
// comment-out the following line and get
// no compiler error/warning - just a program that
// returns uninitted-RAM as an "instance" of X. Scary.
return X();
}
void CallIt() {
MightReturnCheese();
}
};
int main() {
C c;
c.CallIt();
return 0;
}
>Fix:
none known
(though you can pick up the resulting dangerous code
that's generated using something like valgrind)
>Release-Note:
>Audit-Trail:
>Unformatted: