This bugzilla service is closed. All entries have been migrated to https://gitlab.com/libeigen/eigen
Bug 509 - g++ 4.7.1 warning (enumeral and non-enumeral type in conditional expression)
Summary: g++ 4.7.1 warning (enumeral and non-enumeral type in conditional expression)
Status: RESOLVED FIXED
Alias: None
Product: Eigen
Classification: Unclassified
Component: Core - general (show other bugs)
Version: 3.1
Hardware: All All
: Normal Unknown
Assignee: Nobody
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-09-05 16:37 UTC by Benjamin Piwowarski
Modified: 2019-12-04 11:52 UTC (History)
2 users (show)



Attachments
Sample C++ code producing the warning (214 bytes, application/octet-stream)
2012-09-05 16:37 UTC, Benjamin Piwowarski
no flags Details

Description Benjamin Piwowarski 2012-09-05 16:37:08 UTC
Created attachment 294 [details]
Sample C++ code producing the warning

Compiling the attachment with -Wextra results in a warning with g++ 4.7.1 (with g++ 4.2.1 there is no warning)

$ g++-4.7 -Wextra  -o a a.cc

In file included from Eigen/Core:246:0,
                 from Eigen/SparseCore:4,
                 from Eigen/Sparse:17,
                 from a.cc:3:
Eigen/src/Core/util/XprHelper.h: In instantiation of 'struct Eigen::internal::nested<Eigen::SparseSparseProduct<const Eigen::SparseMatrix<double>&, const Eigen::SparseMatrix<double>&>, 1, Eigen::SparseMatrix<double, 6, int> >':
Eigen/src/SparseCore/SparseProduct.h:85:5:   required from 'class Eigen::SparseSparseProduct<const Eigen::SparseMatrix<double>&, const Eigen::SparseMatrix<double>&>'
a.cc:11:32:   required from here
Eigen/src/Core/util/XprHelper.h:296:8: warning: enumeral and non-enumeral type in conditional expression [enabled by default]
Comment 1 Benjamin Piwowarski 2012-09-05 16:49:01 UTC
A quick fix is to modify ScalarReadCostAsInteger and CoeffReadCostAsInteger:

in XprHelper.h (line 304)
...
    ScalarReadCostAsInteger = ScalarReadCost == Dynamic ? int(DynamicAsInteger) : int(ScalarReadCost),
...
    CoeffReadCostAsInteger = CoeffReadCost == Dynamic ? int(DynamicAsInteger) : int(CoeffReadCost),
...
Comment 2 Gael Guennebaud 2012-09-26 23:36:11 UTC
thanks for the report,

https://bitbucket.org/eigen/eigen/changeset/c7a5c5a5658d/
changeset:   c7a5c5a5658d
user:        ggael
date:        2012-09-26 23:32:22
summary:     fix bug 509: warning with gcc 4.7

https://bitbucket.org/eigen/eigen/changeset/8fe4e0bd2fa5/
changeset:   8fe4e0bd2fa5
branch:      3.1
user:        ggael
date:        2012-09-26 23:32:22
summary:     fix bug 509: warning with gcc 4.7
(transplanted from c7a5c5a5658d8b83b7d764b359e908fbc70a985b)
Comment 3 Nobody 2019-12-04 11:52:46 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/509.

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