public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
* [Bug c++/18821] New: Please add warning if bits thrown away in integral conversions @ 2004-12-04 1:16 gccbugzilla at spamit dot net 2004-12-04 1:20 ` [Bug c++/18821] " gccbugzilla at spamit dot net ` (2 more replies) 0 siblings, 3 replies; 7+ messages in thread From: gccbugzilla at spamit dot net @ 2004-12-04 1:16 UTC (permalink / raw) To: gcc-bugs I'd like to get a warning for code like this: #include <iostream> using namespace std; int main() { unsigned long four = 400000; unsigned short two; two = four; cout << two << endl; } /home/enadler/test/compilerwarnings $ g++ -Werror -Wall -Wconversion -ansi gccbugreport.cc && a.out 6784 I think GCC is doing the right thing by allowing this code uncasted, and it is described this way in Bjarne's C++ Programming Language, Special Edition C.6.2.1. However, it seems reasonable to me that a warning option should be available to notify the programmer that data is being thrown away. Thanks! Eric -- Summary: Please add warning if bits thrown away in integral conversions Product: gcc Version: 3.2.3 Status: UNCONFIRMED Severity: enhancement Priority: P2 Component: c++ AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: gccbugzilla at spamit dot net CC: gcc-bugs at gcc dot gnu dot org http://gcc.gnu.org/bugzilla/show_bug.cgi?id=18821 ^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c++/18821] Please add warning if bits thrown away in integral conversions 2004-12-04 1:16 [Bug c++/18821] New: Please add warning if bits thrown away in integral conversions gccbugzilla at spamit dot net @ 2004-12-04 1:20 ` gccbugzilla at spamit dot net 2004-12-06 5:14 ` [Bug c/18821] " pinskia at gcc dot gnu dot org 2005-02-01 21:11 ` [Bug c++/18821] " jsm28 at gcc dot gnu dot org 2 siblings, 0 replies; 7+ messages in thread From: gccbugzilla at spamit dot net @ 2004-12-04 1:20 UTC (permalink / raw) To: gcc-bugs ------- Additional Comments From gccbugzilla at spamit dot net 2004-12-04 01:20 ------- Installed Red Hat Advanced Server 3.0, update 1 Dell PowerEdge 1750: Intel Xeon 2.4GHz Reading specs from /usr/lib/gcc-lib/i386-redhat-linux/3.2.3/specs Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --enable-shared --enable-threads=posix --disable-checking --with-system-zlib --enable-__cxa_atexit --host=i386-redhat-linux Thread model: posix gcc version 3.2.3 20030502 (Red Hat Linux 3.2.3-24) -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=18821 ^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c/18821] Please add warning if bits thrown away in integral conversions 2004-12-04 1:16 [Bug c++/18821] New: Please add warning if bits thrown away in integral conversions gccbugzilla at spamit dot net 2004-12-04 1:20 ` [Bug c++/18821] " gccbugzilla at spamit dot net @ 2004-12-06 5:14 ` pinskia at gcc dot gnu dot org 2005-02-01 21:11 ` [Bug c++/18821] " jsm28 at gcc dot gnu dot org 2 siblings, 0 replies; 7+ messages in thread From: pinskia at gcc dot gnu dot org @ 2004-12-06 5:14 UTC (permalink / raw) To: gcc-bugs ------- Additional Comments From pinskia at gcc dot gnu dot org 2004-12-06 05:14 ------- Confirmed, I thought I saw a bug about this before. -- What |Removed |Added ---------------------------------------------------------------------------- Status|UNCONFIRMED |NEW Component|c++ |c Ever Confirmed| |1 Keywords| |diagnostic Last reconfirmed|0000-00-00 00:00:00 |2004-12-06 05:14:11 date| | http://gcc.gnu.org/bugzilla/show_bug.cgi?id=18821 ^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c++/18821] Please add warning if bits thrown away in integral conversions 2004-12-04 1:16 [Bug c++/18821] New: Please add warning if bits thrown away in integral conversions gccbugzilla at spamit dot net 2004-12-04 1:20 ` [Bug c++/18821] " gccbugzilla at spamit dot net 2004-12-06 5:14 ` [Bug c/18821] " pinskia at gcc dot gnu dot org @ 2005-02-01 21:11 ` jsm28 at gcc dot gnu dot org 2 siblings, 0 replies; 7+ messages in thread From: jsm28 at gcc dot gnu dot org @ 2005-02-01 21:11 UTC (permalink / raw) To: gcc-bugs ------- Additional Comments From jsm28 at gcc dot gnu dot org 2005-02-01 21:10 ------- The example given is in C++, not C; the C version is bug 2707. -- What |Removed |Added ---------------------------------------------------------------------------- Component|c |c++ http://gcc.gnu.org/bugzilla/show_bug.cgi?id=18821 ^ permalink raw reply [flat|nested] 7+ messages in thread
[parent not found: <bug-18821-9730@http.gcc.gnu.org/bugzilla/>]
* [Bug c++/18821] Please add warning if bits thrown away in integral conversions [not found] <bug-18821-9730@http.gcc.gnu.org/bugzilla/> @ 2006-11-26 13:58 ` manu at gcc dot gnu dot org 2006-11-26 13:59 ` manu at gcc dot gnu dot org 2006-11-26 14:04 ` manu at gcc dot gnu dot org 2 siblings, 0 replies; 7+ messages in thread From: manu at gcc dot gnu dot org @ 2006-11-26 13:58 UTC (permalink / raw) To: gcc-bugs [-- Warning: decoded text below may be mangled, UTF-8 assumed --] [-- Attachment #1: Type: text/plain, Size: 866 bytes --] ------- Comment #4 from manu at gcc dot gnu dot org 2006-11-26 13:57 ------- This will be fixed by the new Wconversion option. Actually, it has been fixed already for gcc version 4.3.0 20061124 (experimental). manuel@gcc05:~$ local/bin/g++ -c -Wconversion pr18821.C pr18821.C: In function int main(): pr18821.C:8: warning: conversion to short unsigned int from long unsigned int may alter its value I hope this makes you happy! It is a shame that I missed this bug in the Changelog. Should I modify the Changelog or what is done is done ? -- manu at gcc dot gnu dot org changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |manu at gcc dot gnu dot org http://gcc.gnu.org/bugzilla/show_bug.cgi?id=18821 ^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c++/18821] Please add warning if bits thrown away in integral conversions [not found] <bug-18821-9730@http.gcc.gnu.org/bugzilla/> 2006-11-26 13:58 ` manu at gcc dot gnu dot org @ 2006-11-26 13:59 ` manu at gcc dot gnu dot org 2006-11-26 14:04 ` manu at gcc dot gnu dot org 2 siblings, 0 replies; 7+ messages in thread From: manu at gcc dot gnu dot org @ 2006-11-26 13:59 UTC (permalink / raw) To: gcc-bugs ------- Comment #5 from manu at gcc dot gnu dot org 2006-11-26 13:59 ------- For reference: Author: manu Date: Fri Nov 24 01:50:33 2006 New Revision: 119143 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=119143 Log: 2006-11-24 Manuel Lopez-Ibanez <manu@gcc.gnu.org> PR c/2707 PR c++/26167 * c-common.c (conversion_warning): New. (convert_and_check): Call conversion_warning unless there is an overflow warning. * doc/invoke.texi (-Wconversion): Update description. testsuite/ * gcc.dg/Wconversion-integer.c: New. Supersedes Wconversion-negative-constants.c * gcc.dg/Wconversion-real.c: New. * gcc.dg/Wconversion-real-integer.c: New. * gcc.dg/Wconversion-negative-constants.c: Deleted. * g++.dg/warn/Wconversion1.C: Modified. Added: trunk/gcc/testsuite/gcc.dg/Wconversion-integer.c trunk/gcc/testsuite/gcc.dg/Wconversion-real-integer.c trunk/gcc/testsuite/gcc.dg/Wconversion-real.c Removed: trunk/gcc/testsuite/gcc.dg/Wconversion-negative-constants.c Modified: trunk/gcc/ChangeLog trunk/gcc/c-common.c trunk/gcc/doc/invoke.texi trunk/gcc/testsuite/ChangeLog trunk/gcc/testsuite/g++.dg/warn/Wconversion1.C -- manu at gcc dot gnu dot org changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED Resolution| |FIXED http://gcc.gnu.org/bugzilla/show_bug.cgi?id=18821 ^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c++/18821] Please add warning if bits thrown away in integral conversions [not found] <bug-18821-9730@http.gcc.gnu.org/bugzilla/> 2006-11-26 13:58 ` manu at gcc dot gnu dot org 2006-11-26 13:59 ` manu at gcc dot gnu dot org @ 2006-11-26 14:04 ` manu at gcc dot gnu dot org 2 siblings, 0 replies; 7+ messages in thread From: manu at gcc dot gnu dot org @ 2006-11-26 14:04 UTC (permalink / raw) To: gcc-bugs -- manu at gcc dot gnu dot org changed: What |Removed |Added ---------------------------------------------------------------------------- Target Milestone|--- |4.3.0 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=18821 ^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2006-11-26 14:04 UTC | newest] Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2004-12-04 1:16 [Bug c++/18821] New: Please add warning if bits thrown away in integral conversions gccbugzilla at spamit dot net 2004-12-04 1:20 ` [Bug c++/18821] " gccbugzilla at spamit dot net 2004-12-06 5:14 ` [Bug c/18821] " pinskia at gcc dot gnu dot org 2005-02-01 21:11 ` [Bug c++/18821] " jsm28 at gcc dot gnu dot org [not found] <bug-18821-9730@http.gcc.gnu.org/bugzilla/> 2006-11-26 13:58 ` manu at gcc dot gnu dot org 2006-11-26 13:59 ` manu at gcc dot gnu dot org 2006-11-26 14:04 ` manu at gcc dot gnu dot org
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).