effect of -fPIC on code speed

Ian Lance Taylor iant@google.com
Thu Sep 23 00:03:00 GMT 2010


Jay K <jay.krell@cornell.edu> writes:

> I understand, you can do the pointer equality checks in arbitrary code.
> So there is arbitrary breakage, given a certain uncommon construct.

Function pointer comparisons are part of the C standard and they are
used in real code.  E.g., when I got the pointer equality rules wrong
when working on GNU ld, I broke Tcl.

You can compile libstdc++ in a mode in which it only uses pointer
comparisons for typeinfo comparisons, but it's true that it defaults to
using strcmp.  The comment (libstdc++-v3/libsupc++/typeinfo) says it is
to handle dynamic objects dlopen'ed with RTLD_LOCAL, which is a case
where ELF breaks pointer equality.

Ian



More information about the Gcc-help mailing list