This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: -fPIC changes sizeof class
- From: Andrew Haley <aph at redhat dot com>
- To: "Alan M. Carroll" <amc at network-geographics dot com>
- Cc: gcc-help at gcc dot gnu dot org
- Date: Mon, 10 Aug 2009 10:05:44 +0100
- Subject: Re: -fPIC changes sizeof class
- References: <7.0.0.16.2.20090807113300.03c2f630@wheresmymailserver.com>
Alan M. Carroll wrote:
> I have chased down a crash in my code to -fPIC changing the
> size of a class.
That seems odd.
> My overall project uses some static libraries which are
> compiled without -fPIC and some dynamic libraries that use
> -fPIC. The effect is that if I use a template class in a static
> library and a dynamic library that links to the static library,
> I have to compile the static library with -fPIC as well.
Well, yes. generally speaking, all code in a DSO should be
PIC, and that includes code pulled in from libraries.
> According to the documentation[1] this flag shouldn't have any
> effect at all because I am building for 64 bit Intel.
I can't find that reference. Can you please quote the section to
which you are referring?
> My question is, is this expected behavior? Or should I try to
> get a smaller example that demonstrates the problem?
I can't see why the size of a class should change. However, it's
not a good idea to mix PIC and non-PIC in a DSO.
Andrew.