Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] investigate -Wconversion warnings (close#391) #556

Closed
wants to merge 1 commit into from

Conversation

thirdwing
Copy link
Member

I spent some time investigating the -Wconversion warnings and fixed most of them.

Places I fixed:

(1) string_elt and vector_elt should accept R_xlen_t (https://github.com/wch/r-source/blob/trunk/src/include/Rinternals.h#L557-L558). This is something we really need to fix.

(2) length of vector should be size_t not int.

(3) the hashing functions should return unsigned int as we defined RCPP_HASH (https://github.com/RcppCore/Rcpp/blob/master/inst/include/Rcpp/hash/IndexHash.h#L46)

(4) I think Range sugar should accept R_xlen_t as start and end.

Places I don't fix:

(1) warnings in rowSums.h (https://github.com/RcppCore/Rcpp/blob/master/inst/include/Rcpp/sugar/functions/rowSums.h#L70). I think it is fine.

(2) Date and Datetime. I think @eddelbuettel knows these classes far better than me, so I didn't touch them.

Please take a look @kevinushey @eddelbuettel

@eddelbuettel
Copy link
Member

Wow! Thanks a lot for all this.

I am wondering if we should break this into several separate PRs?

@eddelbuettel
Copy link
Member

In short and without having looked in great detail yet:

(1) Yes, maybe in a separate PR?

(2) In principle, yes. In practice, won't that force a change on a bazillion lines of user code currently using int ?

(3) Yes.

(4) Yes.

These are all excellent points but maybe time to disentangle?

@thirdwing
Copy link
Member Author

It might be better to break into several small PRs. I will do that later.

Let's wait for some opinions from Kevin.

BTW, I know you are working on a new Date class, so I didn't touch them.

@eddelbuettel
Copy link
Member

Sounds good. The branch I am currently in updates the vector version for DateVector and DatetimeVector which are very silly and old. The 'single value' Date and Datetime may stay as is.

@kevinushey
Copy link
Contributor

Nice work! Looks good to me here as well.

@kevinushey
Copy link
Contributor

kevinushey commented Oct 16, 2016

I believe we shouldn't be breaking any user code here -- I think we get automatic integral conversion from int to size_t from the compiler, so at worst users would be seeing some conversion warnings. Does that sound correct?

(some users might still be grumpy about it, though)

@@ -23,12 +23,12 @@
namespace Rcpp {

inline List Module::classes_info(){
int n = classes.size() ;
size_t n = classes.size() ;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kevinushey the size_t changes in this PR are mostly like this. No access from users.

Copy link
Contributor

@kevinushey kevinushey Oct 16, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm thinking more like https://github.com/RcppCore/Rcpp/pull/556/files#diff-a1af5c14c54d6d6907a0ca6f99d61286R69 (although that's int to R_xlen_t, so I misspoke earlier)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I was thinking about what X.size() returns. Internal changes are fine, methinks.

@thirdwing
Copy link
Member Author

Actually there are still tens of warnings about conversion between R_xlen_t and size_t.

They might not be defined as the same on some platforms.

@kevinushey
Copy link
Contributor

Yes, R_xlen_t is defined as ptrdiff_t (https://cran.r-project.org/doc/manuals/r-release/R-ints.html#Long-vectors), which is a signed type. I would expect warnings of that form, and I'm not sure if we want to do anything about it (unless we decide to adopt R_xlen_t as our internal size type over std::size_t)

@eddelbuettel
Copy link
Member

I'm closing this one now as we are taking this one topic at a time which seems a little easier.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants