Skip to content

Commit

Permalink
operator() of `CoeffUnaryOp needs to return by value.
Browse files Browse the repository at this point in the history
Otherwise there is a dangling reference.
  • Loading branch information
Matthias Peschke committed Feb 24, 2024
1 parent 9d614ea commit 6aa5378
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 3 deletions.
1 change: 0 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ add_executable(Instantiator Instantiator.cpp
src/Template.cpp)

# set_target_properties(Instantiator PROPERTIES SUFFIX ${LLVM_VERSION_MAJOR})
target_compile_options(Instantiator -Wno-return-stack-address)

message(STATUS ${CMAKE_SOURCE_DIR})
target_include_directories(Instantiator PRIVATE ${LLVM_INCLUDE_DIRS} ${CLANG_INCLUDE_DIRS} ${CMAKE_SOURCE_DIR}/include)
Expand Down
2 changes: 1 addition & 1 deletion tests/Math/include/Math/CoeffUnaryOp.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class CoeffUnaryOp : public MatrixBase<CoeffUnaryOp<XprType_, ReturnScalar>>
constexpr auto rows() const { return Rows; }
constexpr auto cols() const { return Cols; }

const Scalar& operator()(std::size_t row, std::size_t col) const;
Scalar operator()(std::size_t row, std::size_t col) const;

protected:
const XprType& m_refexpr;
Expand Down
2 changes: 1 addition & 1 deletion tests/Math/src/CoeffUnaryOp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
namespace Math {

template <typename XprType, typename ReturnScalar>
const ReturnScalar& CoeffUnaryOp<XprType, ReturnScalar>::operator()(std::size_t row, std::size_t col) const
ReturnScalar CoeffUnaryOp<XprType, ReturnScalar>::operator()(std::size_t row, std::size_t col) const
{
return m_func(m_refexpr(row, col));
}
Expand Down

0 comments on commit 6aa5378

Please sign in to comment.