This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/35852] -Wconversion rejects bitwise negation and assignment, cannot cast around
- From: "manu at gcc dot gnu dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 22 Aug 2008 13:53:34 -0000
- Subject: [Bug c++/35852] -Wconversion rejects bitwise negation and assignment, cannot cast around
- References: <bug-35852-3227@http.gcc.gnu.org/bugzilla/>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Comment #5 from manu at gcc dot gnu dot org 2008-08-22 13:53 -------
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?
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=35852