[Bug c++/18821] New: Please add warning if bits thrown away in integral conversions

2004-12-03 Thread gccbugzilla at spamit dot net
I'd like to get a warning for code like this:

#include 
using namespace std;
int main()
{
   unsigned long four = 40;
   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


[Bug c++/18821] Please add warning if bits thrown away in integral conversions

2004-12-03 Thread gccbugzilla at spamit dot net

--- 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