Opened 10 years ago
Closed 10 years ago
#437 closed bug (fixed)
negate() should be NTL::negate()
Reported by: | Owned by: | somebody | |
---|---|---|---|
Priority: | major | Milestone: | 3-1-5 and higher |
Component: | factory | Version: | |
Keywords: | g++ ntl negate | Cc: |
Description
In factory/cf_chinese.cc
, the NTL function negate()
is called twice. However, due to a conflict between NTL::negate()
and std::negate()
, compilation fails:
g++ -c cf_chinese.cc -Wall -fno-implicit-templates -I. -I.. -I. -I/release/merger/sage-5.2.rc1/local -I/release/merger/sage-5.2.rc1/local/ include -DHAVE_CONFIG_H -I/release/merger/sage-5.2.rc1/local/include -I/release/merger/sage-5.2.rc1/local/include -I/release/merger/sage-5 .2.rc1/local/include -O2 -g -fPIC -o cf_chinese.o cf_chinese.cc: In function 'CanonicalForm Farey(const CanonicalForm&, const CanonicalForm&)': cf_chinese.cc:214: error: reference to 'negate' is ambiguous /release/merger/sage-5.2.rc1/local/include/NTL/mat_lzz_pE.h:17: error: candidates are: void NTL::negate(NTL::mat_zz_pE&, const NTL::mat_zz _pE&) [...lots more...] /release/merger/sage-5.2.rc1/local/include/NTL/vec_ZZ.h:28: error: candidates are: void NTL::negate(NTL::vec_ZZ&, const NTL::vec_ZZ&) /release/merger/sage-5.2.rc1/local/include/NTL/ZZ.h:301: error: candidates are: void NTL::negate(NTL::ZZ&, const NTL::ZZ&) /usr/include/c++/4.2/bits/stl_function.h:179: error: template<class _Tp> struct std::negate
Changing negate()
to NTL::negate()
fixes this. In Singular 3-1-4-4, this was correct but the NTL::
seems to have been removed in Singular 3-1-5.
Note: Version 3-1-5 isn't available in Trac.
Attachments (1)
Change History (14)
Changed 10 years ago by
Attachment: | NTL_negate.patch added |
---|
comment:1 follow-up: 2 Changed 10 years ago by
NTL:: in front of the negate was removed, because with it it does not compile on Solaris.
comment:2 Changed 10 years ago by
Replying to hannes:
NTL:: in front of the negate was removed, because with it it does not compile on Solaris.
Really? I have compiled Singular-3-1-3-3 (as part of Sage) many times on Solaris and OpenSolaris (with several different versions of GCC) and never had any problem like this. I never tried SunCC, so maybe you're referring to that? Then the NTL::
could be conditionally added:
#ifdef __SUNPRO_CC #define NTL_negate negate #else #define NTL_negate NTL::negate #endif /*...*/ NTL_negate (NTLc, NTLc);
comment:3 Changed 10 years ago by
No, the error occurs with gcc: g++ -c cf_chinese.cc -Wall -fno-implicit-templates -I. -I.. -I. -I/net/lummerland/users/cip/alggeom/hannes/galois32 -I/net/lummerland/users/cip/alggeom/hannes/galois32/SunOS-5/include -DHAVE_CONFIG_H -I/net/lummerland/users/cip/alggeom/hannes/galois32/SunOS-5/include -O2 -fomit-frame-pointer -fno-rtti -fno-exceptions -o cf_chinese.o cf_chinese.cc: In function `CanonicalForm? Farey(const CanonicalForm?&, const
CanonicalForm?&)':
cf_chinese.cc:223: error: `NTL' undeclared (first use this function) cf_chinese.cc:223: error: (Each undeclared identifier is reported only once for
each function it appears in.)
cf_chinese.cc:223: error: parse error before `::' token cf_chinese.cc:228: error: parse error before `::' token
Please check the patch www.singular.uni-kl.de:8002/trac/changeset/15131
#if defined(__STD_FUNCTIONAL__) || defined(_GLIBCXX_FUNCTIONAL) #define NTL_negate NTL::negate #else #define NTL_negate negate #endif
comment:4 Changed 10 years ago by
Singular-3-1-5 even fails to build on Solaris 10 for me (#443), so I cannot really test.
comment:5 follow-up: 6 Changed 10 years ago by
The patch from comment 3 fails to build on Solaris 10 with GCC-4.6.3 and it fails to build on OpenSolaris 06.2009-32 with GCC-4.4.3. In both cases, NTL::
is required but not added by the patch. Singular-3-1-3-3 builds fine on these machines.
comment:6 Changed 10 years ago by
Replying to jdemeyer@…:
The patch from comment 3 fails to build on Solaris 10 with GCC-4.6.3 and it fails to build on OpenSolaris 06.2009-32 with GCC-4.4.3. In both cases,
NTL::
is required but not added by the patch. Singular-3-1-3-3 builds fine on these machines.
Just to clarify: is the NTL_negate macro wrongly defined, i.e. negate instead of std::negate? Or are there additional places in the source where the macro should be placed?
comment:7 Changed 10 years ago by
I guess, that the macros __STD_FUNCTIONAL__
and _GLIBCXX_FUNCTIONAL
depend on the implementation, so this might differ from gcc version to gcc. Since the compiler (suncc?) reports `NTL' undeclared
, one should maybe check for this. It seems to the the actual source of the problem.
comment:8 Changed 10 years ago by
On OpenSolaris, I guess the "correct" macro is _STL_FUNCTION_H
. But you probably shouldn't rely on that.
Which is the version of GCC which fails to build Singular with NTL::
? Because on every system I tried, NTL::negate()
works.
comment:9 Changed 10 years ago by
NTL::negate yields an error with gcc version 3.3.2 and 3.4.2 on SunOS 5.9 sun4u sparc (`NTL' has not been declared)
comment:10 Changed 10 years ago by
Those are really ancient versions of GCC (2003 and 2004 respectively). I think it makes a lot more sense to support more recent versions of GCC.
comment:11 Changed 10 years ago by
Surprising, because gcc 3.4 on another (non-sunos) machine accepts both variants. To solve this, what about the following patch:
#if !defined(__GNUC__) || (__GNUC__ > 3) #define NTL_negate NTL::negate #else #define NTL_negate negate #endif
comment:12 Changed 10 years ago by
That would work for me (but please add a comment mentioning this Trac ticket such that this doesn't get changed again in the future).
comment:13 Changed 10 years ago by
Resolution: | → fixed |
---|---|
Status: | new → closed |
fixed by a test for gcc version <4
Fix