http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49626

           Summary: Explicit conversion skipped when followed by
                    conversion to a wider type
           Product: gcc
           Version: 4.3.2
            Status: UNCONFIRMED
          Severity: minor
          Priority: P3
         Component: c++
        AssignedTo: unassig...@gcc.gnu.org
        ReportedBy: fn42...@fmi.uni-sofia.bg


Hello.

I think I've encountered a case regarding conversions between integral types. 
It is demonstrated by the attached file which, when compiled with
"-Wsign-conversion", makes g++ produce the following warning:

sign-conversion-bug.cpp: In function 'long unsigned int f()':
sign-conversion-bug.cpp:5: warning: conversion to 'long unsigned int' from
'short int' may change the sign of the result

The source code requests two conversions:
1. an explicit one from 'short int' to 'unsigned int';
2. an implicit one from 'unsigned int' to 'unsigned long int'.

However, g++ only seems to attempt a single conversion -- an implicit one from
'short int' to 'unsigned long int'.  Is this the intended behaviour?


Output from "g++ -v":

Using built-in specs.
Target: i486-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Debian 4.3.2-1.1'
--with-bugurl=file:///usr/share/doc/gcc-4.3/README.Bugs
--enable-languages=c,c++,fortran,objc,obj-c++ --prefix=/usr --enable-shared
--with-system-zlib --libexecdir=/usr/lib --without-included-gettext
--enable-threads=posix --enable-nls --with-gxx-include-dir=/usr/include/c++/4.3
--program-suffix=-4.3 --enable-clocale=gnu --enable-libstdcxx-debug
--enable-objc-gc --enable-mpfr --enable-targets=all --enable-cld
--enable-checking=release --build=i486-linux-gnu --host=i486-linux-gnu
--target=i486-linux-gnu
Thread model: posix
gcc version 4.3.2 (Debian 4.3.2-1.1) 


I also tested with gcc versions 4.3.6 and 4.4.6, and I got the same results.


Regards,
Angel Tsankov

Reply via email to