Testcase which should not abort but does currently at -O1 and above because SRA
thinks the decl is constant so it using its DECL_INITIAL but that is NULL so we
get a zero instead of the corect value:
struct sc
{
unsigned v;
static inline sc f(unsigned a);
};
inline sc sc::f(unsigned a)
{
static sc t = { a };
return t;
}
const static sc RC = sc::f( 1 );
extern "C" void abort (void);
int main()
{
sc RC1 = RC;
if (! RC1.v ) abort ();
return 0;
}
--
Summary: [4.1/4.2/4.3 Regression] sometimes TREE_READONLY is
still set for non read only variables causing wrong code
Product: gcc
Version: 4.3.0
Status: UNCONFIRMED
Keywords: wrong-code
Severity: normal
Priority: P3
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: pinskia at gcc dot gnu dot org
GCC target triplet: powerpc-linux-gnu
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31809