Consider -Wconversion warnings

Ouverte
#1,488 10 commentaires 0 réactions 0 personnes assignées Voir sur GitHub

Personne n'a encore pris cette issue.

Évaluation

Difficulté
5/5
Temps estimé
Plus d'une semaine
Accessibilité débutants
35/100
Type d'issue
Refactorisation
Clarté
À clarifier
Activité
Active
Stack technique
cpp
Domaine
build-system

Piste de recherche

Start by reproducing the reported build with clang++ and the -Wconversion flags from the M1mac README. Inspect the warnings, including the example in Rcpp/sugar/functions/mean.h, and determine the agreed scope; done means the project has a documented decision and the selected warnings are resolved or intentionally excluded.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Description

Enabling -Wconversion (particularly with clang++ as on the M1mac machine at CRAN, see its README) exposes a number of warnings. The Oxford machine uses clang++-21, on Ubuntu 26.04 we also have clang++-22 which Vienna uses (without the same options). Per the README this uses

CFLAGS="-falign-functions=8 -g -O2 -Wall -pedantic -Wconversion -Wno-sign-conversion -Wstrict-prototypes"
C17FLAGS="-falign-functions=8 -g -O2 -Wall -pedantic -Wconversion -Wno-sign-conversion -Wno-strict-prototypes"
# ...
CXXFLAGS="-g -O2 -Wall -pedantic -Wconversion -Wno-sign-conversion"

Note that this turns 'sign-conversion' warnings off. Those account for a ton. I found first set of changes we could make by not doing this i.e. by running with only -Wconversion. That may be too radical, but it could still hide some overflows.

Also, our own compilation is 'clean' under -Wconversion -Wno-sign-conversion however other package may see

In file included from /Users/ripley/R/Library/Rcpp/include/Rcpp/sugar/functions/functions.h:63:
/Users/ripley/R/Library/Rcpp/include/Rcpp/sugar/functions/mean.h:38:14: warning: implicit conversion from 'R_xlen_t' (aka 'long') to 'long double' may lose precision [-Wimplicit-int-float-conversion]
   38 |         s /= n;
      |           ~~ ^
/Users/ripley/R/Library/Rcpp/include/Rcpp/sugar/functions/mean.h:44:20: warning: implicit conversion from 'R_xlen_t' (aka 'long') to 'long double' may lose precision [-Wimplicit-int-float-conversion]
   44 |             s += t/n;
      |                   ~^
Langage dominant
C++
Étoiles
799
Forks
219
Merge moyen
5 h 13 min
PR mergées (30 j)
6

Guide de contribution

Ouvrir le guide de contribution

Par où commencer

  1. Lisez l'issue en entier, puis le guide de contribution du projet.
  2. Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
  3. Forkez le dépôt et travaillez sur une branche.
  4. Ouvrez une pull request qui référence le numéro de l'issue.

Autres issues de RcppCore/Rcpp

Toutes les issues de RcppCore/Rcpp

Issues similaires

Plus d'issues C++

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.