Commit 87d9ac49 by Nathan Sidwell Committed by Nathan Sidwell

re PR c++/2823 (kde2/artsd miscompilation (part 1))

cp:
	PR g++/2823
	* semantics.c (expand_body): Don't optimize thunks.
testsuite:
	* g++.old-deja/g++.other/optimize2.C: New file.

From-SVN: r42650
parent 3d04c7c6
2001-05-26 Nathan Sidwell <nathan@codesourcery.com>
PR g++/2823
* semantics.c (expand_body): Don't optimize thunks.
2001-05-25 Sam TH <sam@uchicago.edu>
* cp-tree.h lex.h: Fix header include guards.
......
......@@ -2397,8 +2397,13 @@ expand_body (fn)
timevar_push (TV_INTEGRATION);
/* Optimize the body of the function before expanding it. */
optimize_function (fn);
/* Optimize the body of the function before expanding it. We do not
optimize thunks, as (1) the backend tries to optimize the call to
the thunkee, (b) the tree based inliner breaks that optimization,
(c) virtual functions are rarely inlineable, and (d)
ASM_OUTPUT_MI_THUNK is there to DTRT anyway. */
if (!DECL_THUNK_P (fn))
optimize_function (fn);
timevar_pop (TV_INTEGRATION);
timevar_push (TV_EXPAND);
......
2001-05-26 Nathan Sidwell <nathan@codesourcery.com>
* g++.old-deja/g++.other/optimize2.C: New file.
2001-05-25 Diego Novillo <dnovillo@redhat.com>
* gcc.c-torture/compile/20010518-2.c: New file.
......
// Special g++ Options: -O2
//
// Copyright (C) 2001 Free Software Foundation, Inc.
// Contributed by Nathan Sidwell 26 May 2001 <nathan@codesourcery.com>
// Bug 2823. Inlineing the body of a thunk broke things. But that's
// rarely a sensible thing to do anyway.
#include <cstdio>
#include <cstdlib>
int objCount = 0;
struct Thing
{
int count;
Thing ();
Thing (Thing const &src);
~Thing ();
};
Thing::Thing ()
:count (0)
{
objCount++;
std::printf ("%p %s\n", (void *)this,__PRETTY_FUNCTION__);
}
Thing::Thing (Thing const &src)
:count (0)
{
objCount++;
std::printf ("%p %s\n", (void *)this, __PRETTY_FUNCTION__);
}
Thing::~Thing ()
{
std::printf ("%p %s\n", (void *)this, __PRETTY_FUNCTION__);
if (count)
std::abort ();
count--;
objCount--;
}
void x(Thing name)
{
// destruct name here
}
class Base
{
public:
virtual void test(const Thing& s) = 0;
};
class Impl : virtual public Base
{
public:
virtual void test(const Thing& s)
{
x(s); // copy construct temporary
}
};
int main()
{
Impl *impl = new Impl();
impl->test( Thing ()); // This will use a thunk
return objCount != 0;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment