mapbox / mapbox/cpp

Excellent docs on numeric casting in C++

Offen
#38 1 Kommentar 2 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

Vorherrschende Sprache
Keine Sprachdaten
Sterne
110
Forks
17
PR-Merge-Kennzahlen
Keine gemergten PRs in 30 T.

Beschreibung

Without strict compiler warnings, it is possible to write quite a bit of C++ without it be obvious once needs to study the details of numeric casting. Implicit conversion will convert various integer types to other integer types and to floating point types, quietly and hopefully correctly.

Because we can't have correct code based on hope, we should instead enable warnings from the get go that warn about implicit conversion and specifically truncating or narrowing conversion and convertions that might overflow.

So, we want to enable warnings like `-Wconversion` per #37.

What this means is that you'll get loud warnings right away about converting types and will need to figure out how to avoid or suppress them correctly, to fix the potential existing bugs they hint at and avoid creating new bugs in the process.

Refs https://github.com/mapbox/node-cpp-skel/pull/78#discussion_r144410926 https://github.com/mapbox/carmen-cache/issues/94
refs https://github.com/mapbox/gzip-hpp/pull/19#issuecomment-336537155

/cc @mapsam @GretaCB @flippmoke

Beitragsleitfaden

Beitragsleitfaden öffnen

Erste Schritte

  1. Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
  3. Forke das Repository und arbeite in einem Branch.
  4. Öffne einen Pull Request, der die Issue-Nummer nennt.

Rechercherichtung

Beginne damit, Issue #37 und die darin referenzierten Diskussionen und Pull Requests zu prüfen, um die beabsichtigte Konfiguration der Warnungen zu verstehen. Untersuche anschließend die Build-Konfiguration des Repositorys und kompiliere mit den vorgeschlagenen Konvertierungswarnungen. Erledigt ist die Aufgabe, wenn die Warnungen aktiviert sind und die daraus resultierenden bestehenden Warnungen zu Abschneiden, Verengung, Überlauf oder impliziter Konvertierung behoben oder ausdrücklich unterdrückt wurden.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
cpp
Bereich
build-system, tooling
Issue-Typ
Feature
Schwierigkeit
4/5
Geschätzter Aufwand
3-5 Tage
Aktivitätsstatus
Veraltet
Klarheit
Größtenteils klar
Anfängerfreundlichkeit
35/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.