This forum has been archived. All content is frozen. Please use KDE Discuss instead.

[Wconversion] unexplained warning

Tags: None
(comma "," separated)
protokovol
Registered Member
Posts
3
Karma
0

[Wconversion] unexplained warning

Fri Mar 09, 2012 10:24 am
Hello everyone,

Thank you in advance for your time regarding this matter, I'll make it very short. I reduced my problem to the following snippet :
Code: Select all
#include <Eigen/Dense>

int main()
{
  Eigen::Matrix<double, Eigen::Dynamic, 1> v1, v2;
  v2 = v1.segment(0,2);
}

I'm using the gcc -Wconversion flag (among others) and it produces this yet unexplained error (sorry if it has already been adressed, I didn't find anything related in the forum) :
g++ -Wconversion -Werror -I /usr/local/include/eigen3 eigen_warning.cc -o test
In file included from /usr/local/include/eigen3/Eigen/Core:305:0,
from /usr/local/include/eigen3/Eigen/Dense:1,
from eigen_warning.cc:1:
/usr/local/include/eigen3/Eigen/src/Core/Block.h: In member function ‘void Eigen::Block<XprType, BlockRows, BlockCols, InnerPanel, true>::init() [with XprType = Eigen::Matrix<double, -0x00000000000000001, 1>, int BlockRows = -0x00000000000000001, int BlockCols = 1, bool InnerPanel = false]’:
/usr/local/include/eigen3/Eigen/src/Core/Block.h:304:7: instantiated from ‘Eigen::Block<XprType, BlockRows, BlockCols, InnerPanel, true>::Block(XprType&, Eigen::Block<XprType, BlockRows, BlockCols, InnerPanel, true>::Index, Eigen::Block<XprType, BlockRows, BlockCols, InnerPanel, true>::Index, Eigen::Block<XprType, BlockRows, BlockCols, InnerPanel, true>::Index, Eigen::Block<XprType, BlockRows, BlockCols, InnerPanel, true>::Index) [with XprType = Eigen::Matrix<double, -0x00000000000000001, 1>, int BlockRows = -0x00000000000000001, int BlockCols = 1, bool InnerPanel = false, Eigen::Block<XprType, BlockRows, BlockCols, InnerPanel, true>::Index = long int]’
/usr/local/include/eigen3/Eigen/src/Core/VectorBlock.h:91:61: instantiated from ‘Eigen::VectorBlock<MatrixType, Size>::VectorBlock(VectorType&, Eigen::VectorBlock<MatrixType, Size>::Index, Eigen::VectorBlock<MatrixType, Size>::Index) [with VectorType = Eigen::Matrix<double, -0x00000000000000001, 1>, int Size = -0x00000000000000001, Eigen::VectorBlock<MatrixType, Size>::Index = long int]’
/usr/local/include/eigen3/Eigen/src/Core/VectorBlock.h:127:50: instantiated from ‘Eigen::DenseBase<Derived>::SegmentReturnType Eigen::DenseBase<Derived>::segment(Eigen::DenseBase<Derived>::Index, Eigen::DenseBase<Derived>::Index) [with Derived = Eigen::Matrix<double, -0x00000000000000001, 1>, Eigen::DenseBase<Derived>::SegmentReturnType = Eigen::VectorBlock<Eigen::Matrix<double, -0x00000000000000001, 1>, -0x00000000000000001>, Eigen::DenseBase<Derived>::Index = long int]’
eigen_warning.cc:6:22: instantiated from here
/usr/local/include/eigen3/Eigen/src/Core/Block.h:339:7: error: conversion to ‘int’ from ‘Eigen::Matrix<double, -0x00000000000000001, 1>::Index {aka long int}’ may alter its value [-Werror=conversion]
cc1plus: all warnings being treated as errors

make: *** [Wconversion] Error 1


I'm using Ubuntu 11.10 64 bits. It builds without any warning in an Ubuntu 10.04 LTS 32 bits VB, and I also successfully tried built this on a Linux Mint 10 32 bits.
Any idea where that might come from ? Is there a proper way to use the block/segment methods ?

Thank you for your time and suggestions =)
User avatar
ggael
Moderator
Posts
3447
Karma
19
OS
well you are asking a bit much by turning warnings into errors, but in this particular case we should declare m_outerStride as an Index to avoid this warning.
protokovol
Registered Member
Posts
3
Karma
0

Re: [Wconversion] unexplained warning

Tue Mar 13, 2012 12:47 pm
ggael wrote:well you are asking a bit much by turning warnings into errors, but in this particular case we should declare m_outerStride as an Index to avoid this warning.


The flags are not my choice, as my code is part of a bigger project, and we aim at releasing warning-free versions (so we debug with a very strong warning policy).
Your suggestion solved my problem though, so thank you very much !


Bookmarks



Who is online

Registered users: Bing [Bot], claydoh, Google [Bot], rblackwell, Yahoo [Bot]