Re: [eigen] patches for EIGEN_STATIC_ASSERT

[ Thread Index | Date Index | More lists.tuxfamily.org/eigen Archives ]


> From: Benoit Jacob <jacob.benoit.1@xxxxxxxxx>
> Subject: Re: [eigen] patches for EIGEN_STATIC_ASSERT
> To: eigen@xxxxxxxxxxxxxxxxxxx
> Date: Wednesday, December 17, 2008, 9:57 PM
> Thanks for your patches. In principle I like them, buy my
> GCC 4.3
> doesn't seem to (see below)... which shows that these
> things are
> immensely compiler-dependent and that it's going to be
> difficult to
> find a good solution for everyone.

Well, you're definitely right about that.  I'm currently upgrading my Linux machine to GCC 4.3 so I can test on both platforms in the future.
 
> So I make this counter-proposal to you: how about simply
> turning off
> the MSVC warning with a #pragma ?

That was actually my first thought, but I couldn't figure out where to put the pragma to make it work transparently.  If someone else with MSVC could try to figure it out that would be nice (make sure you're at warning level 4).   Code like this obviously needs to go somewhere in Eigen:

#ifdef (defined _MSC_VER)
  #pragma warning( push )
  #pragma warning( disable: 4127 )
#endif

// code causing warning goes here

#ifdef (defined _MSC_VER)
  #pragma warning( pop )
#endif


> With your 1st patch, the compilation of this program....
> succeeds (no
> compiler output at all)! So i get a binary that of course
> failed on an
> assertion at runtime.

That's probably similar to the issue where I got compilation errors in the tests that GCC didn't due to it ignoring code inside an always false conditional.  It's likely that if I had enabled all MSVC optimizations, I would have gotten the same result.  Perhaps this solution can be massaged a bit to work...

> With your 2nd patch, the compiler output is:

Ya, that definitely is a mouthful.  All MSVC spits out is:

=== BEGIN MSVC OUTPUT =================================

c:\subversion\eigen2\eigen\src/Core/CwiseBinaryOp.h(105) : error C2027: use of undefined type 'Eigen::ei_static_assert<condition,message>'
        with
        [
            condition=false,
            message=Eigen::CwiseBinaryOp<Eigen::ei_scalar_sum_op<double>,Eigen::Matrix<double,4,4>,Eigen::Matrix<double,2,2>>::{ctor}::ERROR_you_mixed_matrices_of_different_sizes
        ]
        c:\subversion\eigen2\eigen\src/Core/CwiseBinaryOp.h(92) : while compiling class template member function 'Eigen::CwiseBinaryOp<BinaryOp,Lhs,Rhs>::CwiseBinaryOp(const Lhs &,const Rhs &,const BinaryOp &)'
        with
        [
            BinaryOp=Eigen::ei_scalar_sum_op<double>,
            Lhs=Eigen::Matrix<double,4,4>,
            Rhs=Eigen::Matrix<double,2,2>
        ]
        ..\..\test\adjoint.cpp(121) : see reference to class template instantiation 'Eigen::CwiseBinaryOp<BinaryOp,Lhs,Rhs>' being compiled
        with
        [
            BinaryOp=Eigen::ei_scalar_sum_op<double>,
            Lhs=Eigen::Matrix<double,4,4>,
            Rhs=Eigen::Matrix<double,2,2>
        ]

=== END MSVC OUTPUT ===================================

My second suggestion is somewhat based off of how Boost and Loki implement static assertions, but they have #ifdefs for various compilers to allow for a little fine-tuning.  I think that may be overkill for Eigen since I don't believe Eigen's static assertions are meant to be generically usable by Eigen users (the enum wouldn't be acceptable if it was).  So I'm going to try to tweak my first solution a bit, and if someone could find a place where that above pragma code can go that actually works, that would also solve the problem.

Thanks,
Kenny Riddile

---


Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/