GNOME Bugzilla – Bug 163314
Lack of conversion warnings
Last modified: 2014-07-22 08:36:46 UTC
The test case (badcast.cc) connects a signal (which unsigned int return type) to a signal handler (with int return type). This compiles without warnings and gives an obviously bad result.
Created attachment 35654 [details] badcast.cc
Created attachment 190049 [details] Warnings from gcc 4.5.2. Warnings or no warnings? It all depends upon the compiler and the compiler options. The gcc manual says "Warnings about conversions between signed and unsigned integers are disabled by default in C++ unless ‘-Wsign-conversion’ is explicitly enabled." The attachment shows the output from gcc with the option -Wsign-conversion. It's not easy to interpret, but there is a warning. The line "badcast.cc:17:34: instantiated from here" gives a clue. If foo is changed to return unsigned int, and to return a non-negative number, there are no warnings.
[Resetting QA Contact and Assignee to default - see bug 659799 for more info]
I compiled badcast.cc with clang++. Just like g++, it prints a warning only if the compiler option -Wsign-conversion is added. -Wall is not enough. clang++ prints a more easy-to-read warning message. Murray, would you mind if I close this bug (resolution Notgnome or perhaps Wontfix or Notabug)? There is nothing that can be done about it in libsigc++.
Sure. Thanks. Done.