After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 163314 - Lack of conversion warnings
Lack of conversion warnings
Status: RESOLVED NOTABUG
Product: libsigc++
Classification: Bindings
Component: signals
2.0
Other Linux
: Normal normal
: ---
Assigned To: libsigc++ maintainer(s)
libsigc++ maintainer(s)
Depends on:
Blocks:
 
 
Reported: 2005-01-08 09:24 UTC by Murray Cumming
Modified: 2014-07-22 08:36 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
badcast.cc (414 bytes, text/plain)
2005-01-08 09:25 UTC, Murray Cumming
Details
Warnings from gcc 4.5.2. (2.33 KB, text/plain)
2011-06-16 14:40 UTC, Kjell Ahlstedt
Details

Description Murray Cumming 2005-01-08 09:24:31 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.
Comment 1 Murray Cumming 2005-01-08 09:25:41 UTC
Created attachment 35654 [details]
badcast.cc
Comment 2 Kjell Ahlstedt 2011-06-16 14:40:38 UTC
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.
Comment 3 André Klapper 2011-09-22 09:02:24 UTC
[Resetting QA Contact and Assignee to default - see bug 659799 for more info]
Comment 4 Kjell Ahlstedt 2014-07-22 07:09:08 UTC
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++.
Comment 5 Murray Cumming 2014-07-22 08:36:46 UTC
Sure. Thanks. Done.