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

2017-01-11 Thread msebor at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=11187

Martin Sebor  changed:

   What|Removed |Added

   Last reconfirmed|2012-01-13 00:00:00 |2017-1-11
 CC||msebor at gcc dot gnu.org
  Known to fail||3.3, 4.5.3, 4.8.3, 4.9.3,
   ||5.3.0, 6.3.0, 7.0

--- Comment #3 from Martin Sebor  ---
The signed case is still accepted by today's trunk.  Clang diagnoses both as
expected.

$ (set -x && cat t.c && for s in signed unsigned; do gcc -DSIGN=$s -S -Wall
-xc++ t.c; done)
+ cat t.c
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;
}
+ for s in signed unsigned
+ gcc -DSIGN=signed -S -Wall -xc++ t.c
+ for s in signed unsigned
+ gcc -DSIGN=unsigned -S -Wall -xc++ t.c
t.c: In function ‘unsigned int test()’:
t.c:12:10: error: ambiguous overload for ‘operator+’ (operand types are
‘Object’ and ‘Object’)
  return a+b;
 ~^~
t.c:12:10: note: candidate: operator+(int, int) 
t.c:12:10: note: candidate: operator+(int, unsigned int) 
t.c:12:10: note: candidate: operator+(unsigned int, int) 
t.c:12:10: note: candidate: operator+(unsigned int, unsigned int) 

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

2004-11-29 Thread nathan at gcc dot gnu dot org

--- Additional Comments From nathan at gcc dot gnu dot org  2004-11-29 
15:00 ---
we miss the signed errors because we keep conversion the short and int functions
on different slots in the member function vector.  I don't think we should be
doing that.  Conversion functions do not have a conventional name, we shouldn't
be pretending they did.

We should fix this when we fix the function vector to use a hash table :)

-- 


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