This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/11187] New: signed/unsigned conversion behaves differently


PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.

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

           Summary: signed/unsigned conversion behaves differently
           Product: gcc
           Version: 3.3
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: c++
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: savoiu@ics.uci.edu
                CC: gcc-bugs@gcc.gnu.org

-- Code ------------------------------------------------
class Object
{
 SIGN short value;
public:
 operator SIGN short() { return value; }
 operator SIGN int()   { return value; }
};

SIGN int test(void)
{
 Object a,b;
 return a+b;
}
-------------------------------------------------------------------
g++ -v
Reading specs from /opt/contrib/gcc-3.3/lib/gcc-lib/sparc-sun-
solaris2.7/3.3/specs
Configured with: ../gcc-3.3/configure --prefix=/opt/contrib/gcc-3.3 --with-gnu-
as --disable-nls --with-gnu-ld --with-as=/opt/contrib/binutils-2.12.1/bin/as --
with-ld=/opt/contrib/binutils-2.12.1/bin/ld --with-cpu=v8
Thread model: posix
gcc version 3.3
-- Case 1 ---------------------------------------------------------
g++ -c -DSIGN=signed bug.cpp -> compiles OK
-- Case 2 ---------------------------------------------------------
g++ -c -DSIGN=unsigned bug.cpp
bug.cpp: In function `unsigned int test()':
bug.cpp:14: error: ambiguous overload for `Object& + Object&' operator
bug.cpp:14: error: candidates are: operator+(unsigned int, unsigned int)
<built-in>
bug.cpp:14: error:                 operator+(unsigned int, int) <built-in>
bug.cpp:14: error:                 operator+(int, unsigned int) <built-in>
bug.cpp:14: error:                 operator+(int, int) <built-in>
-------------------------------------------------------------------


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]