]> www.ginac.de Git - ginac.git/commit
[bugfix] Always #include <lst.h> before using lst. Fixes build error on MinGW.
authorAlexei Sheplyakov <Alexei.Sheplyakov@gmail.com>
Tue, 17 Jul 2012 03:32:45 +0000 (06:32 +0300)
committerAlexei Sheplyakov <Alexei.Sheplyakov@gmail.com>
Tue, 17 Jul 2012 03:32:45 +0000 (06:32 +0300)
commite5eeee53d814cedc12cd725e76b0eb87859cdd77
treeadc114423bfe2002de88a6692f31d0ca44b14999
parent05b3a16973aad40a9c17ee0f0bd06b02ac4706ef
[bugfix] Always #include <lst.h> before using lst. Fixes build error on MinGW.

[temp.expl.spec] says:

6 If a template, a member template or the member of a class template
  is explicitly specialized then that specialization shall be declared
  before the first use of that specialization that would cause an implicit
  instantiation to take place, in every translation unit in which such a
  use occurs; no diagnostic is required. If the program does not provide
  a definition for an explicit specialization and either the specialization
  is used in a way that would cause an implicit instantiation to take place
  or the member is a virtual member function, the program is ill-formed,
  no diagnostic required. An implicit instantiation is never generated for
  an explicit specialization that is declared but not defined.

Apparently we are breaking this rule (presumably since the commit 99901bd5c742
`Parser can now read GiNaC lists (lst) defined by braces.'). In particular,
parser.cpp does not include lst.h (neither directly nor indirectly) which
contains explicit specialization of lst::info(). However, parser.cpp
(indirectly) includes both container.h and registar.h, so the GiNaC::lst type
is declared (and is complete) before the first usage. Thus lst::info() gets
implicitly instantiated (using the general definition provided in container.h)
when compiling the parser.cpp file, and libginac fails to link properly due
to mutliply defined symbols:

libtool: link: ccache i686-w64-mingw32-g++ -shared -nostdlib /usr/lib/gcc/i686-w64-mingw32/4.6/../../../../i686-w64-mingw32/lib/../lib/dllcrt2.o /usr/lib/gcc/i686-w64-mingw32/4.6/crtbegin.o  .libs/add.o .libs/archive.o .libs/basic.o .libs/clifford.o .libs/color.o .libs/constant.o .libs/ex.o .libs/excompiler.o .libs/expair.o .libs/expairseq.o .libs/exprseq.o .libs/fail.o .libs/factor.o .libs/fderivative.o .libs/function.o .libs/idx.o .libs/indexed.o .libs/inifcns.o .libs/inifcns_trans.o .libs/inifcns_gamma.o .libs/inifcns_nstdsums.o .libs/integral.o .libs/lst.o .libs/matrix.o .libs/mul.o .libs/ncmul.o .libs/normal.o .libs/numeric.o .libs/operators.o .libs/power.o .libs/registrar.o .libs/relational.o .libs/remember.o .libs/pseries.o .libs/print.o .libs/symbol.o .libs/symmetry.o .libs/tensor.o .libs/utils.o .libs/wildcard.o .libs/parse_binop_rhs.o .libs/parser.o .libs/parse_context.o .libs/default_reader.o .libs/lexer.o .libs/parser_compat.o .libs/mod_gcd.o .libs/cra_garner.o .libs/upoly_io.o .libs/gcd_uvar.o .libs/chinrem_gcd.o .libs/collect_vargs.o .libs/divide_in_z_p.o .libs/mgcd.o .libs/optimal_vars_finder.o .libs/pgcd.o .libs/primpart_content.o   -L/home/build/GiNaC.pkg/mk/ginac/../../build-tree/inst/all/opt/i686-w64-mingw32/ginac/lib -lcln -L/usr/lib/gcc/i686-w64-mingw32/4.6 -L/usr/lib/gcc/i686-w64-mingw32/4.6/../../../../i686-w64-mingw32/lib/../lib -L/usr/lib/gcc/i686-w64-mingw32/4.6/../../../../i686-w64-mingw32/lib -lstdc++ -lmingw32 -lgcc_s -lgcc -lmoldname -lmingwex -lmsvcrt -ladvapi32 -lshell32 -luser32 -lkernel32 -lmingw32 -lgcc_s -lgcc -lmoldname -lmingwex -lmsvcrt /usr/lib/gcc/i686-w64-mingw32/4.6/crtend.o  -O2 -march=i686 -Wl,--enable-auto-import -Wl,--export-all-symbols   -o .libs/libginac-2.dll -Wl,--enable-auto-image-base -Xlinker --out-implib -Xlinker .libs/libginac.dll.a
Creating library file: .libs/libginac.dll.a
.libs/parser.o: In function `_ZNK5GiNaC9containerISt4listE4infoEj':
/home/build/GiNaC.pkg/mk/ginac/../../ginac/ginac/container.h:359: multiple definition of `GiNaC::container<std::list>::info(unsigned int) const'
.libs/lst.o:/usr/include/c++/4.6/bits/vector.tcc:390: first defined here
collect2: ld returned 1 exit status
make[4]: *** [libginac.la] Error 1
make[4]: Leaving directory `/home/build/GiNaC.pkg/build-tree/build/ginac-1.6.2/ginac'
make[3]: *** [all] Error 2

Thanks to Robert Durkacz for reporting.
ginac/parser/default_reader.cpp
ginac/parser/parser.cpp