[compiler Warnings]: Compile with `-Wconversion` and `-Wsign-conversion` brings up many Warnings

Open
#9,318 5 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
35/100
Issue type
Refactor
Clarity
Needs clarification
Activity status
Quiet
Tech stack
cpp
Domain
compilers

Research direction

Start by compiling the ESP8266 Arduino core with -Wconversion and -Wsign-conversion, then catalog the resulting warnings by source file. The issue does not name files, tests, or a narrower target; done would require addressing the relevant warnings and confirming the flagged build is clean.

Written by the indexing model from the issue text.

Description

Dear Developer Team,

compiling Code with the options:

-Wconversion
-Wsign-conversion

brings up many warnings which should be handled from my point of view.

Maybee it is a good idea to enable this warnings during development.

-Wsign-conversion:

Warn for implicit conversions that may change the sign of an integer value, like assigning a signed integer expression to an unsigned integer variable. An explicit cast silences the warning. In C, this option is enabled also by -Wconversion.

-Wconversion

Warn for implicit conversions that may alter a value. This includes conversions between real and integer, like abs (x) when x is double; conversions between signed and unsigned, like unsigned ui = -1; and conversions to smaller types, like sqrtf (M_PI). Do not warn for explicit casts like abs ((int) x) and ui = (unsigned) -1, or if the value is not changed by the conversion like in abs (2.0). Warnings about conversions between signed and unsigned integers can be disabled by using -Wno-sign-conversion.

For C++, also warn for confusing overload resolution for user-defined conversions; and conversions that never use a type conversion operator: conversions to void, the same type, a base class or a reference to them. Warnings about conversions between signed and unsigned integers are disabled by default in C++ unless -Wsign-conversion is explicitly enabled.

Warnings about conversion from arithmetic on a small type back to that type are only given with -Warith-conversion.
Image
Dominant language
C++
Stars
16.7k
Forks
13.1k
PR merge metrics
No merged PRs in 30d

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from esp8266/Arduino

All issues in esp8266/Arduino

Similar issues

More C++ issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.