[Bug rtl-optimization/25791] -O2 execution fails, -O and -g work
dick_guertin at yahoo dot com
gcc-bugzilla@gcc.gnu.org
Sat Jan 21 08:17:00 GMT 2006
------- Comment #27 from dick_guertin at yahoo dot com 2006-01-21 08:17 -------
Referring to Comment #26, these static objects are NOT all of one type, but
they share a common typedef struct, something like a union of different types
that share the same space. Each type is a constructor allowing initialization
to occur different ways. NKW and 'struct sckw" are two examples, and both
appear in Comment #25.
What I finally did was add a pointer to each object that points to another
object, usually of its own type. But the pointer can by cast so that a
different type can be referenced. Thus the pointer in NKW can be cast as an
NKW pointer even though it points to a 'struct sckw' object, and vice-versa.
To make this work, I had to reverse the declaration order so that the last is
declared first, and the first is declared last. So the new 'first' (old
'last') has a zero pointer. Those which follow point back to the one before
it. This does two things: it guarantees every object is referenced so it
isn't eliminated, and they can now be placed anywhere in memory. Instead of
ticking through them with 'kwp += 1;', I navigate thru them with 'kwp =
kwp->next;'. The chain stops when kwp goes to zero (first declared, last
examined).
In cases where an array of like-kind objects was initialized, I simply point
down the list, such as:
static NKW item[] =
{ SCKW_TOKEN("IF",xif,NKWFSET+NKWFCRTN, &item[1]),
SCKW_TOKEN("SHOW",show,NKWFSET+NKWFCRTN, &item[2]),
SCKW_TOKEN("SET",set,NKWFSET+NKWFCRTN, (NKW*)0)
};
I'm documenting this just in case it can be useful to someone else with a
similar problem.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=25791
More information about the Gcc-bugs
mailing list