mapbox / mapbox/cpp

Excellent docs on numeric casting in C++

未關閉
#38 1 則留言 2 個 reaction 已指派 0 人 在 GitHub 檢視

還沒有人認領這個 Issue。

主要語言
沒有語言資料
星號
110
分支
17
PR 合併指標
30 天內沒有已合併 PR

描述

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

貢獻指南

開啟貢獻指南

從這裡開始

  1. 先讀完整個 Issue,再讀專案的貢獻指南。
  2. 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
  3. Fork 儲存庫,在一個分支上完成修改。
  4. 送出 Pull Request,並在描述裡引用這個 Issue 編號。

研究方向

先檢視 issue #37 以及其中參照的討論和 pull requests,以了解預期的警告設定。接著檢查儲存庫的建置設定,並使用提議的轉換警告進行編譯。當警告已啟用,且由此產生的現有截斷、窄化、溢位或隱式轉換警告已獲得處理或明確抑制時,即表示完成。

由索引模型根據 Issue 內容生成。

評估

技術堆疊
cpp
領域
build-system, tooling
Issue 類型
功能
難度
4/5
預估耗時
3-5 天
活躍度
停滯
描述清晰度
基本清楚
新手友好度
35/100

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。