Hi,
this is the failure of g++.dg/init/struct2.C on Alpha/Tru64, a
regression
introduced by my Tree level constants uniquization patch posted at:
http://gcc.gnu.org/ml/gcc-patches/2010-04/msg01531.html
The varasm.c machinery (decode_addr_const) chockes on the 1st member
of the
initializer:
void saveOrLoad() {
struct Track {
char soundName[15];
};
struct SaveLoadEntry {
int offs;
int type;
int size;
};
struct SaveLoadEntry trackEntries = {
((long) (__SIZE_TYPE__) (&((struct Track *) 42)->soundName
[0])) - 42,
0, 1
};
saveLoadEntries(&trackEntries);
}
because the expression is too complex to be decoded there.
While this machinery could be enhanced, it's worth noting that the
same code
compiles fine with the C compiler on the same platform. That's
because the
offsetof-like expression is folded in build_unary_op:
/* ??? Cope with user tricks that amount to offsetof. Delete
this
when we have proper support for integer constant expressions. */
val = get_base_address (arg);
if (val && TREE_CODE (val) == INDIRECT_REF
&& TREE_CONSTANT (TREE_OPERAND (val, 0)))
{
tree op0 = fold_convert_loc (location, sizetype,
fold_offsetof (arg, val)), op1;
op1 = fold_convert_loc (location, argtype, TREE_OPERAND (val,
0));
ret = fold_build2_loc (location, POINTER_PLUS_EXPR, argtype,
op1, op0);
goto return_build_unary_op;
So the proposed fix is to implement the same folding in the C++
compiler, in
cp_build_unary_op. This yields a couple of regressions:
FAIL: g++.dg/parse/array-size2.C (test for errors, line 16)
FAIL: g++.dg/parse/array-size2.C (test for errors, line 17)
because the C++ compiler can now compile the testcase (as the C
compiler can
compile the counterpart gcc.dg/pr25682.c).