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 摘要。