This bugzilla service is closed. All entries have been migrated to https://gitlab.com/libeigen/eigen
Bug 1264 - AutoDiffScalar: Error in expression (with Apple clang, ok with g++)
Summary: AutoDiffScalar: Error in expression (with Apple clang, ok with g++)
Status: RESOLVED FIXED
Alias: None
Product: Eigen
Classification: Unclassified
Component: Unsupported modules (show other bugs)
Version: 3.3 (current stable)
Hardware: All All
: Normal Compilation Problem
Assignee: Nobody
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-07-27 15:18 UTC by Daniel Vollmer
Modified: 2019-12-04 16:02 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/
Comment 2 Nobody 2019-12-04 16:02:23 UTC
-- GitLab Migration Automatic Message --

This bug has been migrated to gitlab.com's GitLab instance and has been closed from further activity.

You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.com/libeigen/eigen/issues/1264.

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