Valid matrix expression which does not compile

Issue #85 resolved
Mikhail Katliar created an issue

The following code produces compilation errors:

#include <blaze/Math.h>

int main(int, char **)
{
    using blaze::StaticMatrix;

    StaticMatrix<double, 2, 1> B2, B1;
    StaticMatrix<double, 2, 2> A;

    B2 + A * B1;    // <-- OK
    B2 + 0.5 * A * B1;  // <-- Compilation error!

    return 0;
}

Output from g++ 6.2.0:

In file included from /usr/local/include/blaze/math/expressions/SMatDeclDiagExpr.h:46:0,
                 from /usr/local/include/blaze/math/SparseMatrix.h:45,
                 from /usr/local/include/blaze/math/CompressedMatrix.h:48,
                 from /usr/local/include/blaze/Math.h:47,
                 from /home/mkatliar/workspace/tmp/blaze_bug.cpp:1:
/usr/local/include/blaze/math/expressions/DMatDMatAddExpr.h: In instantiation of ‘class blaze::DMatDMatAddExpr<blaze::StaticMatrix<double, 2ul, 1ul>, blaze::DMatScalarMultExpr<blaze::DMatDMatMultExpr<blaze::StaticMatrix<double, 2ul, 2ul>, blaze::StaticMatrix<double, 2ul, 1ul>, false, false, false, false>, double, false>, false>’:
/home/mkatliar/workspace/tmp/blaze_bug.cpp:11:20:   required from here
/usr/local/include/blaze/math/expressions/DMatDMatAddExpr.h:954:4: error: static assertion failed: Invalid matrix/matrix addition expression detected
    BLAZE_CONSTRAINT_MUST_FORM_VALID_MATMATADDEXPR( MT1, MT2 );
    ^

Output from clang++ 3.8.1:

/usr/local/include/blaze/math/expressions/DMatDMatAddExpr.h:954:4: error: static_assert failed "Invalid matrix/matrix addition expression detected"
   BLAZE_CONSTRAINT_MUST_FORM_VALID_MATMATADDEXPR( MT1, MT2 );
   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/local/include/blaze/math/constraints/MatMatAddExpr.h:110:4: note: expanded from macro 'BLAZE_CONSTRAINT_MUST_FORM_VALID_MATMATADDEXPR'
   static_assert( ::blaze::And< ::blaze::IsMatrix<T1> \
   ^              ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/mkatliar/workspace/tmp/blaze_bug.cpp:11:8: note: in instantiation of template class 'blaze::DMatDMatAddExpr<blaze::StaticMatrix<double, 2, 1, false>,
      blaze::DMatScalarMultExpr<blaze::DMatDMatMultExpr<blaze::StaticMatrix<double, 2, 2, false>, blaze::StaticMatrix<double, 2, 1, false>, false, false, false, false>,
      double, false>, false>' requested here
    B2 + 0.5 * A * B1;  // <-- Compilation error!
       ^

Comments (6)

  1. Mikhail Katliar reporter

    Even more minimalistic example:

    #include <blaze/Math.h>
    
    int main(int, char **)
    {
        using blaze::StaticMatrix;
    
        StaticMatrix<double, 2, 1> B2, B1;
    
        B2 + B1;    // <-- OK
        B2 + 0.5 * B1;  // <-- Compilation error!
    
        return 0;
    }
    
  2. Klaus Iglberger

    Hi Mikhail!

    Thanks a lot for pointing out this defect. Unfortunately this defect did not pop up during our tests. We are sorry for the inconveniences and will fix the issue as quickly as possible.

    Best regards,

    Klaus!

  3. Klaus Iglberger

    The fix has been implemented and tested as required. It is immediately available via cloning the Blaze repository and will be officially released in Blaze 3.2.

  4. Log in to comment