"Dwarf error" on Rawhide

Jakub Jelinek jakub at redhat.com
Fri Mar 20 09:55:50 UTC 2009


On Thu, Mar 19, 2009 at 09:15:34AM +0100, Jakub Jelinek wrote:
> On Thu, Mar 19, 2009 at 07:25:42AM +0100, Aurelien Bompard wrote:
> > > I think the undefined references are the real problem there.
> > 
> > Oh, are they ? Any idea what could have changed in GCC 4.4 to cause that ? I 
> > didn't find anything obvious in http://gcc.gnu.org/gcc-4.4/porting_to.html
> 
> Mail me the preprocessed source for tab_ui.cpp (add -save-temps, avoid
> ccache (e.g. run /usr/bin/g++ instead of g++ if you have it installed), mail
> tab_ui.ii it generates) and I can have a look whether it is your package's
> fault or a GCC bug.

What the package does with presets.{h,cpp} is essentially:

presets.h:
template <typename T, int N> struct A { T a; int b; A (T, int); };
const A<int, 3> aint3 = A<int, 3> (6, 3);

presets.cpp:
#include "presets.h"
template <typename T, int N> A<T, N>::A (T t, int i) { a = t; b = i; }

tab_simple.cpp:
#include "presets.h"
int x;

aint3 in the above is being compiled into every CU that includes the header,
but except for presets.cpp the ctor template isn't defined.
In presets.cpp it is only implicitly instantiated, for -O0 nothing is
inlined and the ctors are exported from that CU, but for -O2 the ctor is
inlined and nothing is exported.

You either want to explicitly instantiate it in presets.cpp
(in the simplified testcase add:
template struct A<int, 3>;
), which will export the ctors, or define the ctor in the header as well,
or, perhaps best, don't define all the constants in the presets.h header at
all, just declare them as externs:
extern const A<int, 3> aint3;
and define them all just in presets.cpp.  They can't be optimized away
anyway when the ctor isn't visible.

	Jakub




More information about the fedora-devel-list mailing list