Tested revisions:
r155643 - broken
r155256 - broken
r154886 - broken
r154830 - OK
Command line:
in original testcases, all files are compiled with the same compiler parameters
for this reduced testcase, one file is compiled with "-O1 -fipa-sra", second
with just "-O1"
if -fipa-sra is expected to generate the same code independently on where the
function (destructor) is called from, I will open separate bugreport for that
Output:
g++ file1.cpp -O1 -fipa-sra -c && g++ file2.cpp -O1 -c && g++ file1.o file2.o
&& ./a.out
a.out: header.h:8: Object::~Object(): Assertion `i == 1' failed.
============ header.h ===========
#include <assert.h>
struct Object {
int a, i;
Object() : i(1) {};
__attribute__((noinline)) ~Object()
{
assert(i == 1);
}
void del();
};
============ file1.cpp ==========
#include "header.h"
int main()
{
delete new Object();
(new Object())->del();
return 0;
}
============ file1.cpp ==========
#include "header.h"
void Object::del()
{
delete this;
}
=================================
--
Summary: -fipa-sra can generate different destructors in
different object files, binary breaks after linking
Product: gcc
Version: 4.5.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: tree-optimization
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: zsojka at seznam dot cz
GCC host triplet: x86_64-pc-linux-gnu
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42625