![]() |
Blitz Support : |
From: Julian Cummings (cummings_at_[hidden])
Date: 2005-05-06 23:09:22
Apparently this problem has already been reported to gcc a couple of
different times. The gcc developers feel that they are properly implementing
the C++ standard in this case (although I remain unconvinced at this
point). The compiler complains whenever it tries to instantiate a function
template where one of the template arguments is an unnamed type. It is
illegal to use an unnamed type as a template argument. However, all other
C++ compilers I have access to treat this by simply not considering a
function template as a possible match when one of the arguments is an
unnamed enum. The unnamed enum simply defaults to an integer type. In
other words, you can't overload functions for unnamed argument types, so
don't bother trying possible overload candidates.
In any case, I have gone ahead and converted all of the relevant unnamed
enums in the blitz source code to the appropriate static const type, in
order to work around this annoying new feature of g++-4.0.0. You can get
the updates from the cvs repository in the usual manner. I have checked
that all of the blitz testsuite, example and benchmark codes now build under
gcc-4.0.0 with CXX=g++, F77=gfortran and FC=gfortran. Please let me know if
these changes cause trouble for any other compilers out there.
Thanks, Julian C.
> -----Original Message-----
> From: blitz-support-bounces_at_[hidden]
> [mailto:blitz-support-bounces_at_[hidden]] On Behalf Of
> Julian Cummings
> Sent: Friday, May 06, 2005 5:20 PM
> To: 'Support list for Blitz++'
> Subject: RE: [Blitz-support] Unable to compile with g++-4.0.0
>
> Just wanted to note that I have sent a bug report query to
> the gcc folks regarding this problem. I have isolated the
> cause of the problem in the blitz code, but I am not sure at
> this point if the blitz code is truly incorrect or if this is
> a compiler bug. The compiler is getting confused when we try
> to add or multiply two enumerators from an unnamed enumeration.
> It only gets confused in the presence of templated overloaded
> versions of
> operator+ and operator*. I am puzzled by this behavior because
> operator+ enumerators
> should always be treated as integers in arithmetic
> operations. This problem does not occur with gcc-3.4 and
> earlier versions. I don't know if gcc-4.0 is enforcing some
> bizarre corner case of the ANSI C++ standard or what. I will
> follow up on this once I hear something back from the gcc folks.
>
> Regards, Julian C.
>
> Dr. Julian C. Cummings Office: PB-111
> Caltech/CACR, MC 158-79 Phone: 626-395-2543
> 1200 E. California Blvd. Fax: 626-584-5917
> Pasadena, CA 91125
>
>
> > -----Original Message-----
> > From: blitz-support-bounces_at_[hidden]
> > [mailto:blitz-support-bounces_at_[hidden]] On Behalf Of
> > psong_at_[hidden]
> > Sent: Friday, April 22, 2005 2:39 PM
> > To: blitz-support_at_[hidden]
> > Subject: [Blitz-support] Unable to compile with g++-4.0.0
> >
> > Hello everyone,
> > Today I installed the latest GNU compiler g++-4.0.0 on
> my linux box
> > and started to experiment it with my C++ programs.
> > However, any program using
> > blitz++-0.8 refused to compile. I re-installed blitz++-0.8 using
> > blitz++g++-4.0.0 as
> > the default C++ compiler ($./configure
> > CXX=~/gcc-4.0.0/bin/g++) but the problem persisted. For example, I
> > tried to compile the following program
> >
> >
> > ######################## start of program
> ##########################
> > #include <iostream>
> > #include <blitz/array.h>
> > int main()
> > {
> > blitz::Array<int,2> a1(3,3);
> > return 0;
> > }
> > ######################### end of program
> ############################
> >
> >
> > by doing
> > $~/gcc-4.0.0/bin/g++ -c -Wall -I~/blitz-0.8 foo.cpp I got the
> > following error message:
> >
> >
> > ########################### start of error message
> > ########################
> > ~/blitz-0.8/blitz/meta/product.h: In static member function 'static
> > typename blitz::NumericTypeTraits<typename
> > T_expr1::T_numtype>::T_sumtype blitz::_bz_meta_vectorProduct<N,
> > I>::f(const T_expr1&) [with
> > T_expr1 = blitz::TinyVector<int, 2>, int N = 2, int I = 0]':
> > ~/blitz-0.8/blitz/tvecglobs.h:68: instantiated from 'typename
> > blitz::NumericTypeTraits<P_numtype>::T_sumtype
> > blitz::product(const blitz::TinyVector<P_numtype, N_length>&) [with
> > T_numtype1 = int, int N_length = 2]
> > ~/blitz-0.8/blitz/array-impl.h:986: instantiated from 'int
> > blitz::Array<T,
> > N>::numElements() const [with P_numtype = int, int N_rank = 2]
> > ~/blitz-0.8/blitz/array/methods.cc:254: instantiated from 'void
> > blitz::Array<T, N>::setupStorage(int) [with P_numtype = int, int
> > N_rank = 2]
> > ~/blitz-0.8/blitz/array-impl.h:193: instantiated from
> > 'blitz::Array<T,
> > N>::Array(int, int, blitz::GeneralArrayStorage<N_rank>) [with
> > P_numtype
> > N>=
> > int, int N_rank = 2]
> > test_blitz.cpp:7: instantiated from here
> > ~/blitz-0.8/blitz/meta/product.h:49: error:
> > 'blitz::_bz_meta_vectorProduct<2,
> > 0>::<anonymous enum>' is/uses anonymous type
> > ~/blitz-0.8/blitz/meta/product.h:49: error: trying to instantiate
> > 'template<class T> T blitz::operator*(const T&,
> > blitz::_bz_meta_nullOperand)
> > ~/blitz-0.8/blitz/meta/product.h:49: error:
> > 'blitz::_bz_meta_vectorProduct<2,
> > 0>::<anonymous enum>' is/uses anonymous type
> > ~/blitz-0.8/blitz/meta/product.h:49: error: trying to instantiate
> > 'template<class T> T blitz::operator*(const T&,
> > blitz::_bz_meta_nullOperand)
> > ~/blitz-0.8/blitz/meta/product.h: In static member function 'static
> > typename blitz::NumericTypeTraits<typename
> > T_expr1::T_numtype>::T_sumtype blitz::_bz_meta_vectorProduct<N,
> > I>::f(const T_expr1&) [with
> > T_expr1 = blitz::TinyVector<int, 2>, int N = 2, int I = 1]':
> > ~/blitz-0.8/blitz/meta/product.h:49: instantiated from
> > 'static typename
> > blitz::NumericTypeTraits<typename
> > T_expr1::T_numtype>::T_sumtype
> > blitz::_bz_meta_vectorProduct<N, I>::f(const T_expr1&) [with
> > T_expr1 = blitz::TinyVector<int, 2>, int N = 2, int I = 0]
> > ~/blitz-0.8/blitz/tvecglobs.h:68: instantiated from 'typename
> > blitz::NumericTypeTraits<P_numtype>::T_sumtype
> > blitz::product(const blitz::TinyVector<P_numtype, N_length>&) [with
> > T_numtype1 = int, int N_length = 2]
> > ~/blitz-0.8/blitz/array-impl.h:986: instantiated from 'int
> > blitz::Array<T,
> > N>::numElements() const [with P_numtype = int, int N_rank = 2]
> > ~/blitz-0.8/blitz/array/methods.cc:254: instantiated from 'void
> > blitz::Array<T, N>::setupStorage(int) [with P_numtype = int, int
> > N_rank = 2]
> > ~/blitz-0.8/blitz/array-impl.h:193: instantiated from
> > 'blitz::Array<T,
> > N>::Array(int, int, blitz::GeneralArrayStorage<N_rank>) [with
> > P_numtype
> > N>=
> > int, int N_rank = 2]
> > test_blitz.cpp:7: instantiated from here
> > ~/blitz-0.8/blitz/meta/product.h:49: error:
> > 'blitz::_bz_meta_vectorProduct<2,
> > 1>::<anonymous enum>' is/uses anonymous type
> > ~/blitz-0.8/blitz/meta/product.h:49: error: trying to instantiate
> > 'template<class T> T blitz::operator*(const T&,
> > blitz::_bz_meta_nullOperand)
> > ~/blitz-0.8/blitz/meta/product.h:49: error:
> > 'blitz::_bz_meta_vectorProduct<2,
> > 1>::<anonymous enum>' is/uses anonymous type
> > ~/blitz-0.8/blitz/meta/product.h:49: error: trying to instantiate
> > 'template<class T> T blitz::operator*(const T&,
> > blitz::_bz_meta_nullOperand)
> > make: *** [foo.o] Error 1
> > ############################ end of error message
> > #########################
> >
> >
> > Can anyone tell me why this happens and how can I fix it? Thanks!
> >
> >
> > Best Wishes,
> >
> > Pengcheng Song
> >
> >
> > _______________________________________________
> > Blitz-support mailing list
> > Blitz-support_at_[hidden]
> > http://www.oonumerics.org/mailman/listinfo.cgi/blitz-support
> >
>
>
> _______________________________________________
> Blitz-support mailing list
> Blitz-support_at_[hidden]
> http://www.oonumerics.org/mailman/listinfo.cgi/blitz-support
>