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

[Bug]: Resolve C++ compile warnings #351

Closed
1 task done
ChristineStawitz-NOAA opened this issue Apr 19, 2023 · 13 comments · Fixed by #430
Closed
1 task done

[Bug]: Resolve C++ compile warnings #351

ChristineStawitz-NOAA opened this issue Apr 19, 2023 · 13 comments · Fixed by #430
Labels
kind: bug Something isn't working
Milestone

Comments

@ChristineStawitz-NOAA
Copy link
Contributor

Describe the bug

We should get rid of the warnings and notes that happen at compilation in MQ

To Reproduce

devtools::load_all()

Expected behavior

Expect no warnings

Screenshots

No response

Which OS are you seeing the problem on?

No response

Which browser are you seeing the problem on?

No response

Which version of FIMS are you seeing the problem on?

No response

Additional Context

No response

Code of Conduct

  • I agree to follow this project's Code of Conduct
@ChristineStawitz-NOAA ChristineStawitz-NOAA added the kind: bug Something isn't working label Apr 19, 2023
@ChristineStawitz-NOAA ChristineStawitz-NOAA self-assigned this Apr 19, 2023
@ChristineStawitz-NOAA ChristineStawitz-NOAA added this to the MQ milestone Apr 19, 2023
@msupernaw
Copy link
Contributor

The -w flag removes all warnings on Unix and I believe Linux platforms. Not sure what flag is required for MakeVars.win.

@Andrea-Havron-NOAA
Copy link
Collaborator

Andrea-Havron-NOAA commented Aug 2, 2023

@ChristineStawitz-NOAA and @msupernaw, should we be editing the Makevars.win file to ignore the warnings or fixing them? I think most are coming from a comparison between types size_t and int, e.g.:
for (int j = 0; j < nages; j++)
where nages is size_t

We could either declare j as size_t or cast nages to int inside the for loop expression to fix all the warnings.

@ChristineStawitz-NOAA
Copy link
Contributor Author

Are the only warnings size_t vs int? If so I think we should fix. I thought when I filed this issue there were warnings that we didn't want to fix, but maybe those are gone now?

Thanks!

@Andrea-Havron-NOAA
Copy link
Collaborator

There are two other warnings:

  • rcpp_population: for (size_t i = 0; i < log_init_naa.size(); i++): warning: comparison of integer expressions of different signedness: 'size_t{aka 'long long unsigned int and 'R_xlen_t{aka 'long long int-Wsign-compare
  • data_object: size_t jmax;: warning: fims::DataObject::jmaxl be initialized after [-Wreorder

@msupernaw
Copy link
Contributor

msupernaw commented Aug 2, 2023 via email

@ChristineStawitz-NOAA
Copy link
Contributor Author

I think the data_object warning is when you change the orders of when jmax is initialized, maybe if the documentation has it in a different order than the functor?

@msupernaw
Copy link
Contributor

You need to change the dimension member as the first thing initialized in DataObject.
For example, you should change DataObject(size_t imax) : imax(imax), dimensions(1) to DataObject(size_t imax) : dimensions(1), imax(imax). You'l need to do this for all constructors.

@Andrea-Havron-NOAA
Copy link
Collaborator

Thanks! For the rcpp_population warning, should we cast log_init_naa.size() as size_t? log_init_naa is declared as an Rcpp::NumericVector

@msupernaw
Copy link
Contributor

@Andrea-Havron-NOAA Yes, I think so. The Rcpp documentation says log_init_naa.size() returns a R_xlen_t type, which is typdefed here as either a ptrdiff_t or an int depending on the preprocessing macro. Both are signed integers.

@ChristineStawitz-NOAA
Copy link
Contributor Author

I found this issue on it in Rcpp..RcppCore/Rcpp#811

It looks like R_xlen_t type is not signed - is it possible turning the index to an int will fix this since an int is signed?

@msupernaw
Copy link
Contributor

@ChristineStawitz-NOAA According to Rinternals.h, R_xlen_t is definitely signed. It's typedef'd as a ptrdiff_t or int and both are signed. If the documentation is not correct, the best way to tell is to print typeid(x).name() to standard out. If "m" is returned, it's a size_t, if "i" is returned, it's an integer.

@msupernaw
Copy link
Contributor

Hmm, a quick test on my computer says it's a long!

Rcpp::NumericVector nv;
Rcpp::Rcout<<"vector type: "<<typeid(nv.size()).name()<<std::endl;

Output:
vector type: l

@ChristineStawitz-NOAA
Copy link
Contributor Author

sorry typo above, I meant to say it is signed, not that it isn't signed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind: bug Something isn't working
Projects
No open projects
Status: Done
Development

Successfully merging a pull request may close this issue.

4 participants