New user self-registration is currently disabled. Please email eigen-core-team @ lists.tuxfamily.org if you need an account.
Bug 1264 - AutoDiffScalar: Error in expression (with Apple clang, ok with g++)
AutoDiffScalar: Error in expression (with Apple clang, ok with g++)
Status: RESOLVED FIXED
Product: Eigen
Classification: Unclassified
Component: Unsupported modules
3.3 (current stable)
All All
: Normal Compilation Problem
Assigned To: Nobody
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2016-07-27 15:18 UTC by Daniel Vollmer
Modified: 2016-07-27 21:33 UTC (History)
2 users (show)



Attachments

Description Daniel Vollmer 2016-07-27 15:18:50 UTC
This example fails in the 3.3beta-2, but only when compiling with clang, gcc seems ok. I *think* the same code worked in the 3.2 branch for both compilers, but I'm not 100% positive I tested clang (gcc definitely worked).

#include "Eigen/Core"
#include "unsupported/Eigen/AutoDiff"

using namespace Eigen;

int main (int argc, char const *argv[])
{
  using AD = AutoDiffScalar<Matrix<double, 5, 1> >;

  const double _muRef = 0.0, _TSutherland = 0.0, _temperatureReNormalizationFactor = 0.0;
  const AD temp;
  const Matrix<AD, 3, 1> dTemperature;


  const AD ad;
  
  const Matrix<AD, 3, 1> dMu = _muRef * sqrt(temp) * (1.0 + _TSutherland) / ((temp + _TSutherland) * (temp + _TSutherland))
    * 0.5 * (temp + 3.0 * _TSutherland) * _temperatureReNormalizationFactor * dTemperature;

  return 0;
}

The error is:
> clang++ -std=c++11 eigen_3.3_repo4.cpp -I thirdparty/eigen-3.3/
In file included from eigen_3.3_repo4.cpp:2:
In file included from thirdparty/eigen-3.3/unsupported/Eigen/AutoDiff:32:
thirdparty/eigen-3.3/unsupported/Eigen/src/AutoDiff/AutoDiffScalar.h:680:44: error: type 'Eigen::Matrix<double, 5, 1, 0, 5, 1> &' cannot be used prior to '::' because it has no members
  : NumTraits< typename NumTraits<typename DerType::Scalar>::Real >
                                           ^
thirdparty/eigen-3.3/Eigen/src/Core/util/XprHelper.h:69:17: note: in instantiation of template class 'Eigen::NumTraits<Eigen::AutoDiffScalar<Eigen::Matrix<double, 5, 1, 0, 5, 1> &> >' requested here
  bool IsSafe = NumTraits<T>::IsInteger || !NumTraits<PromotedType>::IsInteger>
                ^
thirdparty/eigen-3.3/Eigen/src/Core/util/XprHelper.h:74:40: note: in instantiation of default argument for 'promote_scalar_arg_unsupported<double, Eigen::AutoDiffScalar<Eigen::Matrix<double, 5, 1, 0, 5, 1> &>, double,
      false>' required here
struct promote_scalar_arg<S,T,false> : promote_scalar_arg_unsupported<S,T,typename NumTraits<S>::Literal> {};
                                       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
thirdparty/eigen-3.3/Eigen/src/Core/../plugins/CommonCwiseBinaryOps.h:50:1: note: in instantiation of template class 'Eigen::internal::promote_scalar_arg<double, Eigen::AutoDiffScalar<Eigen::Matrix<double, 5, 1, 0, 5, 1>
      &>, false>' requested here
EIGEN_MAKE_SCALAR_BINARY_OP(operator*,product)
^
thirdparty/eigen-3.3/Eigen/src/Core/util/Macros.h:946:3: note: expanded from macro 'EIGEN_MAKE_SCALAR_BINARY_OP'
  EIGEN_MAKE_SCALAR_BINARY_OP_ONTHELEFT(METHOD,OPNAME) \
  ^
thirdparty/eigen-3.3/Eigen/src/Core/util/Macros.h:938:112: note: expanded from macro 'EIGEN_MAKE_SCALAR_BINARY_OP_ONTHELEFT'
  EIGEN_MSVC10_WORKAROUND_BINARYOP_RETURN_TYPE(const EIGEN_SCALAR_BINARYOP_EXPR_RETURN_TYPE(typename internal::promote_scalar_arg<Scalar EIGEN_COMMA T EIGEN_COMMA EIGEN_SCALAR_BINARY_SUPPORTED(OPNAME,T,Scalar)>::typ...
                                                                                                               ^
eigen_3.3_repo4.cpp:17:100: note: while substituting deduced template arguments into function template 'operator*' [with T = Eigen::AutoDiffScalar<Eigen::Matrix<double, 5, 1, 0, 5, 1> &>]
  const Matrix<AD, 3, 1> dMu = _muRef * sqrt(temp) * (1.0 + _TSutherland) / ((temp + _TSutherland) * (temp + _TSutherland))
                                                                                                   ^
In file included from eigen_3.3_repo4.cpp:2:
In file included from thirdparty/eigen-3.3/unsupported/Eigen/AutoDiff:32:
thirdparty/eigen-3.3/unsupported/Eigen/src/AutoDiff/AutoDiffScalar.h:682:61: error: type 'Eigen::Matrix<double, 5, 1, 0, 5, 1> &' cannot be used prior to '::' because it has no members
  typedef AutoDiffScalar<Matrix<typename NumTraits<typename DerType::Scalar>::Real,DerType::RowsAtCompileTime,DerType::ColsAtCompileTime,
                                                            ^
thirdparty/eigen-3.3/unsupported/Eigen/src/AutoDiff/AutoDiffScalar.h:686:39: error: type 'Eigen::Matrix<double, 5, 1, 0, 5, 1> &' cannot be used prior to '::' because it has no members
  typedef typename NumTraits<typename DerType::Scalar>::Literal Literal;
                                      ^
3 errors generated.


i.e. DerType is substituted as a reference in that case.

> clang++ -v
Apple LLVM version 7.3.0 (clang-703.0.31)
Target: x86_64-apple-darwin15.6.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin

g++ 6.1.0 doesn't cause a problem.
Comment 1 Gael Guennebaud 2016-07-27 21:33:05 UTC
https://bitbucket.org/eigen/eigen/commits/0b62bc896f80/

Note You need to log in before you can comment on or make changes to this bug.