Skip to content

Excellent docs on numeric casting in C++ #38

Open
@springmeyer

Description

@springmeyer

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 mapbox/node-cpp-skel#78 (comment) mapbox/carmen-cache#94
refs mapbox/gzip-hpp#19 (comment)

/cc @mapsam @GretaCB @flippmoke

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions