From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 9034 invoked by alias); 4 Dec 2004 01:16:08 -0000 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org Received: (qmail 9014 invoked by uid 48); 4 Dec 2004 01:16:03 -0000 Date: Sat, 04 Dec 2004 01:16:00 -0000 From: "gccbugzilla at spamit dot net" To: gcc-bugs@gcc.gnu.org Message-ID: <20041204011601.18821.gccbugzilla@spamit.net> Reply-To: gcc-bugzilla@gcc.gnu.org Subject: [Bug c++/18821] New: Please add warning if bits thrown away in integral conversions X-Bugzilla-Reason: CC X-SW-Source: 2004-12/txt/msg00568.txt.bz2 List-Id: I'd like to get a warning for code like this: #include 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