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

Fix compiler warning - comparison of signed and unsigned integers #1218

Merged
merged 3 commits into from
Jul 25, 2024

Conversation

kylebaron
Copy link
Collaborator

@kylebaron kylebaron commented Jul 25, 2024

Fixing a type (int to size_t) warning based on winbuilder output (#1217). This is a harmless compiler warning, but going to fix this now to get it as clean as possible.

start gets passed in from j, which is size_t because we're always comparing to object.size(). This PR just makes it consistent and should avoid the compiler warning for comparing signed and unsigned integers.

@kylebaron
Copy link
Collaborator Author

No longer getting this compiler warning:

* installing *source* package 'mrgsolve' ...
** package 'mrgsolve' successfully unpacked and MD5 sums checked
** using staged installation
** libs
using C++ compiler: 'g++.exe (GCC) 13.2.0'
g++ -std=gnu++17  -I"D:/RCompile/recent/R/include" -DNDEBUG -I../inst/include -I../inst/base -g -I. -I'D:/RCompile/CRANpkg/lib/4.5/Rcpp/include' -I'D:/RCompile/CRANpkg/lib/4.5/RcppArmadillo/include' -I'D:/RCompile/CRANpkg/lib/4.5/BH/include'   -I"d:/rtools44/x86_64-w64-mingw32.static.posix/include"     -pedantic -O2 -Wall  -mfpmath=sse -msse2 -mstackrealign  -c LSODA.cpp -o LSODA.o
g++ -std=gnu++17  -I"D:/RCompile/recent/R/include" -DNDEBUG -I../inst/include -I../inst/base -g -I. -I'D:/RCompile/CRANpkg/lib/4.5/Rcpp/include' -I'D:/RCompile/CRANpkg/lib/4.5/RcppArmadillo/include' -I'D:/RCompile/CRANpkg/lib/4.5/BH/include'   -I"d:/rtools44/x86_64-w64-mingw32.static.posix/include"     -pedantic -O2 -Wall  -mfpmath=sse -msse2 -mstackrealign  -c RcppExports.cpp -o RcppExports.o
g++ -std=gnu++17  -I"D:/RCompile/recent/R/include" -DNDEBUG -I../inst/include -I../inst/base -g -I. -I'D:/RCompile/CRANpkg/lib/4.5/Rcpp/include' -I'D:/RCompile/CRANpkg/lib/4.5/RcppArmadillo/include' -I'D:/RCompile/CRANpkg/lib/4.5/BH/include'   -I"d:/rtools44/x86_64-w64-mingw32.static.posix/include"     -pedantic -O2 -Wall  -mfpmath=sse -msse2 -mstackrealign  -c dataobject.cpp -o dataobject.o
g++ -std=gnu++17  -I"D:/RCompile/recent/R/include" -DNDEBUG -I../inst/include -I../inst/base -g -I. -I'D:/RCompile/CRANpkg/lib/4.5/Rcpp/include' -I'D:/RCompile/CRANpkg/lib/4.5/RcppArmadillo/include' -I'D:/RCompile/CRANpkg/lib/4.5/BH/include'   -I"d:/rtools44/x86_64-w64-mingw32.static.posix/include"     -pedantic -O2 -Wall  -mfpmath=sse -msse2 -mstackrealign  -c datarecord.cpp -o datarecord.o
g++ -std=gnu++17  -I"D:/RCompile/recent/R/include" -DNDEBUG -I../inst/include -I../inst/base -g -I. -I'D:/RCompile/CRANpkg/lib/4.5/Rcpp/include' -I'D:/RCompile/CRANpkg/lib/4.5/RcppArmadillo/include' -I'D:/RCompile/CRANpkg/lib/4.5/BH/include'   -I"d:/rtools44/x86_64-w64-mingw32.static.posix/include"     -pedantic -O2 -Wall  -mfpmath=sse -msse2 -mstackrealign  -c devtran.cpp -o devtran.o
g++ -std=gnu++17  -I"D:/RCompile/recent/R/include" -DNDEBUG -I../inst/include -I../inst/base -g -I. -I'D:/RCompile/CRANpkg/lib/4.5/Rcpp/include' -I'D:/RCompile/CRANpkg/lib/4.5/RcppArmadillo/include' -I'D:/RCompile/CRANpkg/lib/4.5/BH/include'   -I"d:/rtools44/x86_64-w64-mingw32.static.posix/include"     -pedantic -O2 -Wall  -mfpmath=sse -msse2 -mstackrealign  -c housemodel-mread-source.cpp -o housemodel-mread-source.o
g++ -std=gnu++17  -I"D:/RCompile/recent/R/include" -DNDEBUG -I../inst/include -I../inst/base -g -I. -I'D:/RCompile/CRANpkg/lib/4.5/Rcpp/include' -I'D:/RCompile/CRANpkg/lib/4.5/RcppArmadillo/include' -I'D:/RCompile/CRANpkg/lib/4.5/BH/include'   -I"d:/rtools44/x86_64-w64-mingw32.static.posix/include"     -pedantic -O2 -Wall  -mfpmath=sse -msse2 -mstackrealign  -c mrgsolve.cpp -o mrgsolve.o
In file included from D:/RCompile/CRANpkg/lib/4.5/BH/include/boost/mpl/aux_/na_assert.hpp:23,
                 from D:/RCompile/CRANpkg/lib/4.5/BH/include/boost/mpl/arg.hpp:25,
                 from D:/RCompile/CRANpkg/lib/4.5/BH/include/boost/mpl/placeholders.hpp:24,
                 from D:/RCompile/CRANpkg/lib/4.5/BH/include/boost/iterator/iterator_categories.hpp:16,
                 from D:/RCompile/CRANpkg/lib/4.5/BH/include/boost/iterator/iterator_adaptor.hpp:14,
                 from D:/RCompile/CRANpkg/lib/4.5/BH/include/boost/token_iterator.hpp:22,
                 from D:/RCompile/CRANpkg/lib/4.5/BH/include/boost/tokenizer.hpp:20,
                 from mrgsolve.cpp:29:
D:/RCompile/CRANpkg/lib/4.5/BH/include/boost/mpl/assert.hpp:194:21: warning: unnecessary parentheses in declaration of 'assert_arg' [-Wparentheses]
  194 | failed ************ (Pred::************
      |                     ^~~~~~~~~~~~~~~~~~~
  195 |       assert_arg( void (*)(Pred), typename assert_arg_pred<Pred>::type )
      |       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  196 |     );

Compare with

* installing *source* package 'mrgsolve' ...
** package 'mrgsolve' successfully unpacked and MD5 sums checked
** using staged installation
** libs
using C++ compiler: 'g++.exe (GCC) 13.2.0'
g++ -std=gnu++17  -I"D:/RCompile/recent/R/include" -DNDEBUG -I../inst/include -I../inst/base -g -I. -I'D:/RCompile/CRANpkg/lib/4.5/Rcpp/include' -I'D:/RCompile/CRANpkg/lib/4.5/RcppArmadillo/include' -I'D:/RCompile/CRANpkg/lib/4.5/BH/include'   -I"d:/rtools44/x86_64-w64-mingw32.static.posix/include"     -pedantic -O2 -Wall  -mfpmath=sse -msse2 -mstackrealign  -c LSODA.cpp -o LSODA.o
g++ -std=gnu++17  -I"D:/RCompile/recent/R/include" -DNDEBUG -I../inst/include -I../inst/base -g -I. -I'D:/RCompile/CRANpkg/lib/4.5/Rcpp/include' -I'D:/RCompile/CRANpkg/lib/4.5/RcppArmadillo/include' -I'D:/RCompile/CRANpkg/lib/4.5/BH/include'   -I"d:/rtools44/x86_64-w64-mingw32.static.posix/include"     -pedantic -O2 -Wall  -mfpmath=sse -msse2 -mstackrealign  -c RcppExports.cpp -o RcppExports.o
g++ -std=gnu++17  -I"D:/RCompile/recent/R/include" -DNDEBUG -I../inst/include -I../inst/base -g -I. -I'D:/RCompile/CRANpkg/lib/4.5/Rcpp/include' -I'D:/RCompile/CRANpkg/lib/4.5/RcppArmadillo/include' -I'D:/RCompile/CRANpkg/lib/4.5/BH/include'   -I"d:/rtools44/x86_64-w64-mingw32.static.posix/include"     -pedantic -O2 -Wall  -mfpmath=sse -msse2 -mstackrealign  -c dataobject.cpp -o dataobject.o
g++ -std=gnu++17  -I"D:/RCompile/recent/R/include" -DNDEBUG -I../inst/include -I../inst/base -g -I. -I'D:/RCompile/CRANpkg/lib/4.5/Rcpp/include' -I'D:/RCompile/CRANpkg/lib/4.5/RcppArmadillo/include' -I'D:/RCompile/CRANpkg/lib/4.5/BH/include'   -I"d:/rtools44/x86_64-w64-mingw32.static.posix/include"     -pedantic -O2 -Wall  -mfpmath=sse -msse2 -mstackrealign  -c datarecord.cpp -o datarecord.o
datarecord.cpp: In function 'void insert_record(reclist&, int, rec_ptr&, bool)':
datarecord.cpp:600:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::deque<std::shared_ptr<datarecord> >::size_type' {aka 'long long unsigned int'} [-Wsign-compare]
  600 |     for(i = start + 1; i < thisi.size(); ++i) {
      |                        ~~^~~~~~~~~~~~~~
datarecord.cpp:606:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::deque<std::shared_ptr<datarecord> >::size_type' {aka 'long long unsigned int'} [-Wsign-compare]
  606 |     for(i = start + 1; i < thisi.size(); ++i) {
      |                        ~~^~~~~~~~~~~~~~
g++ -std=gnu++17  -I"D:/RCompile/recent/R/include" -DNDEBUG -I../inst/include -I../inst/base -g -I. -I'D:/RCompile/CRANpkg/lib/4.5/Rcpp/include' -I'D:/RCompile/CRANpkg/lib/4.5/RcppArmadillo/include' -I'D:/RCompile/CRANpkg/lib/4.5/BH/include'   -I"d:/rtools44/x86_64-w64-mingw32.static.posix/include"     -pedantic -O2 -Wall  -mfpmath=sse -msse2 -mstackrealign  -c devtran.cpp -o devtran.o
g++ -std=gnu++17  -I"D:/RCompile/recent/R/include" -DNDEBUG -I../inst/include -I../inst/base -g -I. -I'D:/RCompile/CRANpkg/lib/4.5/Rcpp/include' -I'D:/RCompile/CRANpkg/lib/4.5/RcppArmadillo/include' -I'D:/RCompile/CRANpkg/lib/4.5/BH/include'   -I"d:/rtools44/x86_64-w64-mingw32.static.posix/include"     -pedantic -O2 -Wall  -mfpmath=sse -msse2 -mstackrealign  -c housemodel-mread-source.cpp -o housemodel-mread-source.o
g++ -std=gnu++17  -I"D:/RCompile/recent/R/include" -DNDEBUG -I../inst/include -I../inst/base -g -I. -I'D:/RCompile/CRANpkg/lib/4.5/Rcpp/include' -I'D:/RCompile/CRANpkg/lib/4.5/RcppArmadillo/include' -I'D:/RCompile/CRANpkg/lib/4.5/BH/include'   -I"d:/rtools44/x86_64-w64-mingw32.static.posix/include"     -pedantic -O2 -Wall  -mfpmath=sse -msse2 -mstackrealign  -c mrgsolve.cpp -o mrgsolve.o
In file included from D:/RCompile/CRANpkg/lib/4.5/BH/include/boost/mpl/aux_/na_assert.hpp:23,
                 from D:/RCompile/CRANpkg/lib/4.5/BH/include/boost/mpl/arg.hpp:25,
                 from D:/RCompile/CRANpkg/lib/4.5/BH/include/boost/mpl/placeholders.hpp:24,
                 from D:/RCompile/CRANpkg/lib/4.5/BH/include/boost/iterator/iterator_categories.hpp:16,
                 from D:/RCompile/CRANpkg/lib/4.5/BH/include/boost/iterator/iterator_adaptor.hpp:14,
                 from D:/RCompile/CRANpkg/lib/4.5/BH/include/boost/token_iterator.hpp:22,
                 from D:/RCompile/CRANpkg/lib/4.5/BH/include/boost/tokenizer.hpp:20,
                 from mrgsolve.cpp:29:
D:/RCompile/CRANpkg/lib/4.5/BH/include/boost/mpl/assert.hpp:194:21: warning: unnecessary parentheses in declaration of 'assert_arg' [-Wparentheses]
  194 | failed ************ (Pred::************

@kylebaron kylebaron requested a review from kyleam July 25, 2024 20:43
@kylebaron kylebaron changed the title Fix/int type Fix compiler warning - comparison of signed and unsigned integers Jul 25, 2024
@kylebaron kylebaron merged commit 2eabaa7 into release/1.5.0 Jul 25, 2024
7 checks passed
@kylebaron kylebaron deleted the fix/int-type branch July 25, 2024 21:51
@kylebaron kylebaron mentioned this pull request Jul 25, 2024
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.

2 participants