public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/20416] Incorrect lifetime for temporary with static const reference
[not found] <bug-20416-10246@http.gcc.gnu.org/bugzilla/>
2005-11-21 16:09 ` [Bug c++/20416] Incorrect lifetime for temporary with static const reference rsandifo at gcc dot gnu dot org
@ 2005-11-21 16:09 ` rsandifo at gcc dot gnu dot org
2006-04-19 15:09 ` pinskia at gcc dot gnu dot org
` (4 subsequent siblings)
6 siblings, 0 replies; 9+ messages in thread
From: rsandifo at gcc dot gnu dot org @ 2005-11-21 16:09 UTC (permalink / raw)
To: gcc-bugs
------- Comment #1 from rsandifo at gcc dot gnu dot org 2005-11-21 16:09 -------
Confirmed. Here's a dejagnu-style testcase:
// PR c++/20416. We correctly constructed the temporary S in foo(),
// but incorrectly destroyed it every time foo() was called.
// { dg-do run }
extern "C" void abort (void);
namespace { int counter; }
struct S {
S() { counter++; }
S(const S &) { counter++; }
~S() { counter--; }
};
void
foo (void)
{
static const S &s = S();
if (counter != 1)
abort ();
}
int main ()
{
if (counter != 0)
abort ();
foo ();
foo ();
}
--
rsandifo at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |rsandifo at gcc dot gnu dot
| |org
Status|UNCONFIRMED |NEW
Ever Confirmed|0 |1
Known to fail| |3.4.5 4.1.0
Last reconfirmed|0000-00-00 00:00:00 |2005-11-21 16:09:00
date| |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=20416
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug c++/20416] Incorrect lifetime for temporary with static const reference
[not found] <bug-20416-10246@http.gcc.gnu.org/bugzilla/>
@ 2005-11-21 16:09 ` rsandifo at gcc dot gnu dot org
2005-11-21 16:09 ` rsandifo at gcc dot gnu dot org
` (5 subsequent siblings)
6 siblings, 0 replies; 9+ messages in thread
From: rsandifo at gcc dot gnu dot org @ 2005-11-21 16:09 UTC (permalink / raw)
To: gcc-bugs
------- Comment #2 from rsandifo at gcc dot gnu dot org 2005-11-21 16:09 -------
BTW, this is 12.2/5.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=20416
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug c++/20416] Incorrect lifetime for temporary with static const reference
[not found] <bug-20416-10246@http.gcc.gnu.org/bugzilla/>
2005-11-21 16:09 ` [Bug c++/20416] Incorrect lifetime for temporary with static const reference rsandifo at gcc dot gnu dot org
2005-11-21 16:09 ` rsandifo at gcc dot gnu dot org
@ 2006-04-19 15:09 ` pinskia at gcc dot gnu dot org
2006-10-05 20:38 ` pinskia at gcc dot gnu dot org
` (3 subsequent siblings)
6 siblings, 0 replies; 9+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2006-04-19 15:09 UTC (permalink / raw)
To: gcc-bugs
------- Comment #3 from pinskia at gcc dot gnu dot org 2006-04-19 15:08 -------
*** Bug 27216 has been marked as a duplicate of this bug. ***
--
pinskia at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |jkanze at cheuvreux dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=20416
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug c++/20416] Incorrect lifetime for temporary with static const reference
[not found] <bug-20416-10246@http.gcc.gnu.org/bugzilla/>
` (2 preceding siblings ...)
2006-04-19 15:09 ` pinskia at gcc dot gnu dot org
@ 2006-10-05 20:38 ` pinskia at gcc dot gnu dot org
2007-10-04 1:46 ` jason at gcc dot gnu dot org
` (2 subsequent siblings)
6 siblings, 0 replies; 9+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2006-10-05 20:38 UTC (permalink / raw)
To: gcc-bugs
------- Comment #4 from pinskia at gcc dot gnu dot org 2006-10-05 20:38 -------
*** Bug 29360 has been marked as a duplicate of this bug. ***
--
pinskia at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |amylaar at gcc dot gnu dot
| |org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=20416
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug c++/20416] Incorrect lifetime for temporary with static const reference
[not found] <bug-20416-10246@http.gcc.gnu.org/bugzilla/>
` (3 preceding siblings ...)
2006-10-05 20:38 ` pinskia at gcc dot gnu dot org
@ 2007-10-04 1:46 ` jason at gcc dot gnu dot org
2007-10-04 17:58 ` jason at gcc dot gnu dot org
2007-10-04 18:01 ` jason at gcc dot gnu dot org
6 siblings, 0 replies; 9+ messages in thread
From: jason at gcc dot gnu dot org @ 2007-10-04 1:46 UTC (permalink / raw)
To: gcc-bugs
--
jason at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
AssignedTo|unassigned at gcc dot gnu |jason at gcc dot gnu dot org
|dot org |
Status|NEW |ASSIGNED
Last reconfirmed|2006-02-20 18:40:42 |2007-10-04 01:45:58
date| |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=20416
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug c++/20416] Incorrect lifetime for temporary with static const reference
[not found] <bug-20416-10246@http.gcc.gnu.org/bugzilla/>
` (4 preceding siblings ...)
2007-10-04 1:46 ` jason at gcc dot gnu dot org
@ 2007-10-04 17:58 ` jason at gcc dot gnu dot org
2007-10-04 18:01 ` jason at gcc dot gnu dot org
6 siblings, 0 replies; 9+ messages in thread
From: jason at gcc dot gnu dot org @ 2007-10-04 17:58 UTC (permalink / raw)
To: gcc-bugs
------- Comment #5 from jason at gcc dot gnu dot org 2007-10-04 17:58 -------
Subject: Bug 20416
Author: jason
Date: Thu Oct 4 17:58:07 2007
New Revision: 129020
URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=129020
Log:
PR c++/20416
* call.c (initialize_reference): Handle local static reference
temps properly.
Added:
trunk/gcc/testsuite/g++.dg/init/ref15.C
Modified:
trunk/gcc/cp/ChangeLog
trunk/gcc/cp/call.c
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=20416
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug c++/20416] Incorrect lifetime for temporary with static const reference
[not found] <bug-20416-10246@http.gcc.gnu.org/bugzilla/>
` (5 preceding siblings ...)
2007-10-04 17:58 ` jason at gcc dot gnu dot org
@ 2007-10-04 18:01 ` jason at gcc dot gnu dot org
6 siblings, 0 replies; 9+ messages in thread
From: jason at gcc dot gnu dot org @ 2007-10-04 18:01 UTC (permalink / raw)
To: gcc-bugs
------- Comment #6 from jason at gcc dot gnu dot org 2007-10-04 18:00 -------
Fixed for 4.3.0.
--
jason at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|ASSIGNED |RESOLVED
Known to work| |4.3.0
Resolution| |FIXED
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=20416
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug c++/20416] Incorrect lifetime for temporary with static const reference
[not found] <bug-20416-4@http.gcc.gnu.org/bugzilla/>
2014-07-12 2:22 ` shri314 at yahoo dot com
@ 2014-07-13 5:02 ` jason at gcc dot gnu.org
1 sibling, 0 replies; 9+ messages in thread
From: jason at gcc dot gnu.org @ 2014-07-13 5:02 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=20416
Jason Merrill <jason at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Known to fail| |
--- Comment #8 from Jason Merrill <jason at gcc dot gnu.org> ---
(In reply to shri314@yahoo.com from comment #7)
> Issue exists in 4.1.2 as well.
GCC 4.1 is no longer supported upstream; if you're seeing this with the RHEL5
system compiler, please report it to Red Hat bugzilla. The patch seems like a
fine candidate for backporting.
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug c++/20416] Incorrect lifetime for temporary with static const reference
[not found] <bug-20416-4@http.gcc.gnu.org/bugzilla/>
@ 2014-07-12 2:22 ` shri314 at yahoo dot com
2014-07-13 5:02 ` jason at gcc dot gnu.org
1 sibling, 0 replies; 9+ messages in thread
From: shri314 at yahoo dot com @ 2014-07-12 2:22 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=20416
shri314 at yahoo dot com <shri314 at yahoo dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |shri314 at yahoo dot com
--- Comment #7 from shri314 at yahoo dot com <shri314 at yahoo dot com> ---
Issue exists in 4.1.2 as well. And it can cause heap corruption from seemingly
mundane and regular pieces of code:
<snip>
#include <string>
std::string::size_type foo() {
const static std::string& bad = "r=";
return bad.size();
}
int main() {
foo();
foo();
}
</snip>
valgrind shows "invalid free"
-----------------------------
> ERROR SUMMARY: 5 errors from 3 contexts (suppressed: 18 from 9)
>
> 1 errors in context 1 of 3:
> Invalid free() / delete / delete[]
> at 0x40054B4: operator delete(void*) (vg_replace_malloc.c:346)
> by 0x4095C9C: std::string::_Rep::_M_destroy(std::allocator<char> const&) (in /usr/lib/libstdc++.so.6.0.8)
> by 0x804871B: foo() (basic_string.h:233)
> by 0x804875A: main (A.cpp:13)
> Address 0x410e028 is 0 bytes inside a block of size 15 free'd
> at 0x40054B4: operator delete(void*) (vg_replace_malloc.c:346)
> by 0x4095C9C: std::string::_Rep::_M_destroy(std::allocator<char> const&) (in /usr/lib/libstdc++.so.6.0.8)
> by 0x804871B: foo() (basic_string.h:233)
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2014-07-13 5:02 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <bug-20416-10246@http.gcc.gnu.org/bugzilla/>
2005-11-21 16:09 ` [Bug c++/20416] Incorrect lifetime for temporary with static const reference rsandifo at gcc dot gnu dot org
2005-11-21 16:09 ` rsandifo at gcc dot gnu dot org
2006-04-19 15:09 ` pinskia at gcc dot gnu dot org
2006-10-05 20:38 ` pinskia at gcc dot gnu dot org
2007-10-04 1:46 ` jason at gcc dot gnu dot org
2007-10-04 17:58 ` jason at gcc dot gnu dot org
2007-10-04 18:01 ` jason at gcc dot gnu dot org
[not found] <bug-20416-4@http.gcc.gnu.org/bugzilla/>
2014-07-12 2:22 ` shri314 at yahoo dot com
2014-07-13 5:02 ` 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).