This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: failed attempt: retain identifier length from frontend to backend


>>>>> "Dimitris" == Dimitrios Apostolou <jimis@gmx.net> writes:

Dimitris> [...] since I broke things like the static assert in
Dimitris> libcpp/identifiers.c, that I don't even understand:

Dimitris>  /* We don't need a proxy since the hash table's identifier comes first
Dimitris>     in cpp_hashnode.  However, in case this is ever changed, we have a
Dimitris>     static assertion for it.  */
Dimitris> -extern char proxy_assertion_broken[offsetof (struct cpp_hashnode, ident) == 0 ? 1 : -1];

This assertion is because the implementation of cpp_forall_identifiers
relies on the layout of cpp_hashnode:

void
cpp_forall_identifiers (cpp_reader *pfile, cpp_cb cb, void *v)
{
  ht_forall (pfile->hash_table, (ht_cb) cb, v);
}

The idea is that since the identifier comes first, we can walk the hash
table directly using ht_forall, relying on an implicit cast to convert
the ht_identifier* to a cpp_hashnode*.

This is somewhat bogus -- casts of functions are almost never good.
(In gdb at least we tend to be more pedantic about this kind of thing.
But this code has been in libcpp a long time...)

If the struct were laid out differently, then cpp_forall_identifiers
would need an intermediate function to do the conversion and then call
'cb'.

Tom


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]