This forum has been archived. All content is frozen. Please use KDE Discuss instead.

[Solved] Compiler Error

Tags: None
(comma "," separated)
kinetic
Registered Member
Posts
15
Karma
0

[Solved] Compiler Error

Thu Aug 13, 2009 10:16 pm
I tried posting this on the mailing list but it did not seem to go through. Apologies if I am double posting this. (I'm actually not to concerned about it)

On some obsure compilers:

i586-mingw32msvc-g++ --version
i586-mingw32msvc-g++ (GCC) 4.2.1-sjlj (mingw32-2)
(mingw installed for cross-compiling for windows on Linux)

gccxml --version
GCC-XML version 0.9.0

I am getting a compilation error:

In file included from /src/eigen2/Eigen/Core:182,
eigen2/Eigen/src/Core/Product.h:68: internal compiler error: Segmentation fault
Please submit a full bug report,
with preprocessed source if appropriate.
See <URL:http://www.mingw.org/bugs.shtml> for instructions.

The code in question:
Code: Select all
template<typename Lhs, typename Rhs> struct ei_product_type
{
 enum {
   Rows  = Lhs::RowsAtCompileTime,
   Cols  = Rhs::ColsAtCompileTime,
   Depth = EIGEN_ENUM_MIN(Lhs::ColsAtCompileTime,Rhs::RowsAtCompileTime),

   value = ei_product_type_selector<(Rows
>=EIGEN_CACHEFRIENDLY_PRODUCT_THRESHOLD ? Large : (Rows==1   ? 1 :
Small)),
                                    (Cols
>=EIGEN_CACHEFRIENDLY_PRODUCT_THRESHOLD ? Large : (Cols==1   ? 1 :
Small)),

(Depth>=EIGEN_CACHEFRIENDLY_PRODUCT_THRESHOLD ? Large : (Depth==1  ? 1
: Small))>::ret  /// LINE 182 IS HERE
 };
};

This error is relatively new (I used to be able to cross compile with this tool). I see it on a Ubuntu and Fedora box with two different compiler versions. I'm not too concerned but this option is nice to have. Any ideas how to resolve this, or what the problem is? Other than this strange case everything compiles fine with gcc on linux, or "tdm-mingw" and msvc on windows.

Thanks

Last edited by kinetic on Fri Aug 14, 2009 2:47 am, edited 1 time in total.
User avatar
bjacob
Registered Member
Posts
658
Karma
3

Re: Compiler Error

Fri Aug 14, 2009 1:38 am
"internal compiler error : segmentation fault" really means that you hit a bug in the compiler itself, and a big one!

the best that we can do on eigen's side is to try to work around it. the most useful thing that you could do, would be to bisect to find the exact revision that triggers the bug.


Join us on Eigen's IRC channel: #eigen on irc.freenode.net
Have a serious interest in Eigen? Then join the mailing list!
kinetic
Registered Member
Posts
15
Karma
0

Re: Compiler Error

Fri Aug 14, 2009 2:47 am
I was able to compile with a cross compiler based on GCC 4.4.0. So if this is just a bug in the compiler I think we can declare this solved. If you would like me to trace the problem further I can if it is helpful to you, but I don't see the point if later versions rectify the problem.

Thanks for the quick response. Sorry for the dumb question.
User avatar
bjacob
Registered Member
Posts
658
Karma
3

Re: [Solved] Compiler Error

Fri Aug 14, 2009 3:16 am
it wasn't a dumb question, but indeed _I_ don't care personnally, so if you don't need us to look for a workaround for the older compiler, then I don't care either! It's great that the newer cross-compiler works.


Join us on Eigen's IRC channel: #eigen on irc.freenode.net
Have a serious interest in Eigen? Then join the mailing list!
kinetic
Registered Member
Posts
15
Karma
0

Re: [Solved] Compiler Error

Thu Aug 20, 2009 6:01 am
I tried compiling my program on a few other platforms with GCC and got the same error. I am receiving this error now on FreeBSD and Mac OS X in addition to the above. Both of these are based on older versions of GCC. The error on BSD is perhaps a little more informative though:

On BSD:
Code: Select all
$ g++ --version
g++ (GCC) 4.2.1 20070719  [FreeBSD]
Copyright (C) 2007 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.


I get an error:
Code: Select all
g++ -o lib/referencecountedobject.os -c -O -Wall -pedantic -Wno-long-long -g -g2 -fPIC -I/usr/home/tirons/src/eigen2 -Iinclude src/referencecountedobject.cpp
In file included from include/emmodfd.h:86,
                 from include/referencecountedobject.h:37,
                 from src/referencecountedobject.cpp:34:
/usr/home/tirons/src/eigen2/Eigen/StdVector:5:2: error: #error you must include Eigen/StdVector before std::vector
In file included from /usr/include/xmmintrin.h:42,
                 from /usr/include/emmintrin.h:34,
                 from /usr/home/tirons/src/eigen2/Eigen/Core:33,
                 from include/emmodfd.h:83,
                 from include/referencecountedobject.h:37,
                 from src/referencecountedobject.cpp:34:
/usr/include/mm_malloc.h:37: error: declaration of 'int posix_memalign(void**, size_t, size_t) throw ()' throws different exceptions
/usr/include/stdlib.h:161: error: from previous declaration 'int posix_memalign(void**, size_t, size_t)'
In file included from include/emmodfd.h:86,
                 from include/referencecountedobject.h:37,
                 from src/referencecountedobject.cpp:34:
/usr/include/c++/4.2/bits/stl_vector.h:159: error: previous declaration 'template<class _Tp, class _Alloc> class std::vector'
/usr/home/tirons/src/eigen2/Eigen/StdVector:88: error: used 2 template parameter(s) instead of 3
/usr/home/tirons/src/eigen2/Eigen/StdVector:88: error: expected template-name before '<' token
/usr/home/tirons/src/eigen2/Eigen/StdVector:95: error: wrong number of template arguments (3, should be 2)
/usr/include/c++/4.2/bits/stl_vector.h:159: error: provided for 'template<class _Tp, class _Alloc> class std::vector'
/usr/home/tirons/src/eigen2/Eigen/StdVector:96: error: expected template-name before '<' token
scons: *** [lib/referencecountedobject.os] Error 1
scons: building terminated because of errors.


The error about Eigen/StdVector is due to including Eigen/Sparse before Eigen/StdVector. Easy enough to remedy, but I thought I would bring it to your attention. The other errors are over my head. Changing the ordering of the includes to remove this problem yields:

Code: Select all
g++ -o lib/referencecountedobject.os -c -O -Wall -pedantic -Wno-long-long -g -g2 -fPIC -I/usr/home/tirons/src/eigen2 -Iinclude src/referencecountedobject.cpp
In file included from /usr/include/xmmintrin.h:42,
                 from /usr/include/emmintrin.h:34,
                 from /usr/home/tirons/src/eigen2/Eigen/Core:62,
                 from include/emmodfd.h:83,
                 from include/referencecountedobject.h:37,
                 from src/referencecountedobject.cpp:34:
/usr/include/mm_malloc.h:37: error: declaration of 'int posix_memalign(void**, size_t, size_t) throw ()' throws different exceptions
/usr/include/stdlib.h:161: error: from previous declaration 'int posix_memalign(void**, size_t, size_t)'
/usr/home/tirons/src/eigen2/Eigen/src/Core/Product.h:68: confused by earlier errors, bailing out
scons: *** [lib/referencecountedobject.os] Error 1
scons: building terminated because of errors.


I get this with the mercurial tip version but not with 2.0.4 and earlier. I don't know how to revert to versions between 2.0.4 and the latest in Mercurial though.

The following is a minimal program that exhibits both errors:
Code: Select all
#include <Eigen/Core>
#include <Eigen/Array>
#include <Eigen/Sparse>

// Uncomment to get std vector error, goes away if this comes before
// sparse include
//#include <Eigen/StdVector>

int main() {
    std::cout << "Hello whirld\n";
}


And compiling with

Code: Select all
g++ min.cpp  -I/usr/home/tirons/src/eigen2/ -o min:w


Will generate both compiler errors. I can to more to help but I am at a loss at this point.

Thanks.
User avatar
bjacob
Registered Member
Posts
658
Karma
3

Re: [Solved] Compiler Error

Thu Aug 20, 2009 2:44 pm
Thank you very much! That seems like a lot of useful info. I'll look at it as soon as possible, just busy at the moment.


Join us on Eigen's IRC channel: #eigen on irc.freenode.net
Have a serious interest in Eigen? Then join the mailing list!
User avatar
bjacob
Registered Member
Posts
658
Karma
3

Re: [Solved] Compiler Error  Topic is solved

Thu Aug 20, 2009 4:29 pm
OK, good news:

- the internal compiler error should be "fixed" (i.e. worked around) now. I could only test with gcc-4.1 which had the problem too, please confirm for gcc 4.2. My distro somehow didn't have gcc 4.2 packages.

- about the error message about the #include order, first it is only in 2.0 and the problem doesn't exist in the devel branch; in 2.0 it's really required to include files in that order and the issue is that Sparse includes <vector>. So I just changed the #error message to make it more helpful, that will be in 2.0.5.


Join us on Eigen's IRC channel: #eigen on irc.freenode.net
Have a serious interest in Eigen? Then join the mailing list!
kinetic
Registered Member
Posts
15
Karma
0

Re: [Solved] Compiler Error

Thu Aug 20, 2009 5:26 pm
I can confirm that this work around allows compilation on Mac OS X g++ version 4.0.1. Thanks!

I am still seeing the the problem on BSD with my application. However, I do not see it with the minimal program above. (Strange)
So there may be some issue with my code. If I can trace what is causing it from within my application I will let you know.

Thanks so much for the fast response!
kinetic
Registered Member
Posts
15
Karma
0

Re: [Solved] Compiler Error

Thu Aug 20, 2009 8:13 pm
Benoit:

FYI Cross compilation using gcc 4.2.1 targeting windows was successful as well.(I still haven't figured out the BSD problem)

Thanks so much.
User avatar
bjacob
Registered Member
Posts
658
Karma
3

Re: [Solved] Compiler Error

Thu Aug 20, 2009 8:19 pm
Cool :)


Join us on Eigen's IRC channel: #eigen on irc.freenode.net
Have a serious interest in Eigen? Then join the mailing list!
User avatar
bjacob
Registered Member
Posts
658
Karma
3

Re: [Solved] Compiler Error

Thu Aug 20, 2009 8:22 pm
About your BSD problem, this looks awfully like a bug in the standard libraries you have in your system:

Code: Select all
/usr/include/mm_malloc.h:37: error: declaration of 'int posix_memalign(void**, size_t, size_t) throw ()' throws different exceptions
/usr/include/stdlib.h:161: error: from previous declaration 'int posix_memalign(void**, size_t, size_t)'


see, on one side it has the throw() and not on the other side. maybe you have to manually edit one to make it match the other. sorry i don't know for sure which one is right.


Join us on Eigen's IRC channel: #eigen on irc.freenode.net
Have a serious interest in Eigen? Then join the mailing list!
kinetic
Registered Member
Posts
15
Karma
0

Re: [Solved] Compiler Error

Thu Aug 20, 2009 8:27 pm
I discovered that BSD compiles without the pedantic flag. You are probably right about the underlying problem.

merci beaucoup


Bookmarks



Who is online

Registered users: Bing [Bot], Google [Bot], Sogou [Bot]