Matrix erroneously constructible from empty std::string

Summary

Matrix is constructible from empty std::string() (I believe through some implicit casting), e.g. Eigen::Matrix2d m(std::string());, which I don't believe it should be. It is worth noting that non-empty strings do not compile, e.g. Eigen::Matrix2d m(std::string("1");. This means that the std::is_constructible<MatrixType, std::string> type trait is true, e.g. std::is_constructible<Eigen::Matrix<double, 2, 2>, std::string>::value == true. In my case, this created a problem with the nlohmann::json C++ library, and I had originally raised an issue there, however now believe it is an Eigen issue.

Environment

  • Operating System : Linux (Ubuntu 18.04)
  • Architecture : x64
  • Eigen Version : 3.4.0
  • Compiler Version : gcc7.5
  • Compile Flags : Debug and Release
  • Vector Extension : n/a

Minimal Example

Eigen::Matrix2d m(std::string());
std::cerr << m << std::endl; // prints 1
std::cerr << (std::is_constructible<Eigen::Matrix<double, 2, 2>, std::string>::value ? "passed!" : "failed!") << std::endl; // prints passed!

What is the current bug behavior?

Eigen matrices are constructible from empty strings, and pass std::is_constructible<MatrixType, std::string>::value test.

What is the expected correct behavior?

They should not be constructible from empty strings, and should fail std::is_constructible<MatrixType, std::string>::value test.

Anything else that might help