Skip to content

subvector_stl_iterator::operator-> triggers 'taking address of rvalue' warning

Submitted by James Beach

Assigned to Nobody

Link to original bugzilla bug (#1776)
Version: 3.4 (development)

Description

Given the following:

auto x = Eigen::ArrayXXd(2, 3);  
x << 0.0, 1.0, 2.0,  
     3.0, 4.0, 5.0;  
  
for (auto it = x.colwise().cbegin(); it != x.colwise().cend(); ++it)  
    std::cout << "x = " <&lt; it-&gt;coeff(0) << '\n';  

GCC 9.2.1 reports:

.../src/Core/StlIterators.h:254:48: error: taking address of rvalue [-fpermissive]  

No such warning is triggered if we use operator* instead:

std::cout << "x = " << (*it).coeff(0) << '\n';  

as would be done implicitly if we were to use range-based for.

Blocking

#814 (closed)

Edited by Eigen Bugzilla