Bug 6044 - -Wconversion is not enabled by default
Summary: -Wconversion is not enabled by default
Status: NEW
Alias: None
Product: uClibc
Classification: Unclassified
Component: Other (show other bugs)
Version: 0.9.33.3
Hardware: PC Linux
: P5 minor
Target Milestone: ---
Assignee: unassigned
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-03-02 23:20 UTC by Jeffrey Walton
Modified: 2013-03-02 23:20 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jeffrey Walton 2013-03-02 23:20:41 UTC
-Wconversion is not enabled by default. Closely related is -Wsign-conversion (included in -Wconversion), which is also not present. -Wconversion is enabled by "Enable extra annoying warnings" (EXTRA_WARNINGS).

-Wconversion and -Wsign-conversion are important because -1 > 1 after C/C++ promotion rules. The following will likely produce unexpected results:

  int x = GetX(); // assume -1
  unsinged int y = GetY(); // assume 1

  if(x > y)
    printf("%d is greater than %u", x, y);
  else
    printf("%d is not greater than %u", x, y);

Apparently, one of the uClibc developer was bitten by this or a similar langauge feature. From Rules.mak:

# Why -funsigned-char: I hunted a bug related to incorrect
# sign extension of 'char' type for 10 hours straight. Not fun.
CPU_CFLAGS-y := -funsigned-char -fno-builtin

-Wconversion can produce a lot of output, but the output is usually correct. Its painful to turn the warning on for a mature product because a lot of slop has crept into the project. It only "annoying" because the programmers have not been mindful of details :)