------- Comment #7 from fang at csl dot cornell dot edu  2008-08-29 04:54 
-------
(In reply to comment #5)
> This is the current situation as of revision 139373.
> 
> typedef unsigned short  ushort;
> 
> enum {
>         FOO = 0x13
> };
> 
> template <typename T>
> inline
> void
> andnot(T& lv, const T& rv) {
>   lv &= ~rv; // -Wconversion  int(lv) & ~(int(rv))
> }
> 
> int
> main(int, char*[]) {
>   ushort x = 99;
>   x = ~FOO;               // -Wsign-conversion -20 -> unsigned short
>   x &= ~FOO;              // -Wconversion int(x) & ~(int(19)) -> unsigned 
> short
>   x = x & ~FOO;           // -Wconversion int(x) & ~(int(19)) -> unsigned 
> short
>   x = x & ushort(~FOO);   // no warning
>   x = x & ushort(~ushort(FOO));   // no warning
>   x &= static_cast<ushort>(~FOO); // no warning
>   x &= ~x;                        // no warning
>   andnot(x, ushort(FOO)); // instantiated from here
>   return x;
> }
> 
> I don't see what is wrong with the warnings. Would you mind elaborating?

The situation then seems to have improved since I first reported it. 
Originally, none of the cases with explicit casts would pass, but comment #4
suggests that those have been fixed.  I expect the cast-less cases to have
warnings.  (I would consider this fixed.)


-- 


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

Reply via email to