Re: [PATCH 1/2] fix clang -Wconstant-conversion with bit fields
On Wed, Jan 16, 2013 at 11:47:22PM +0100, Antoine Pelisse wrote: clang incorrectly reports a constant conversion warning (implicit truncation to bit field) when using the flag = ~FLAG form, because ~FLAG needs to be truncated. Convert this form to flag = flag ~FLAG fixes the issue as the right operand now fits into the bit field. Signed-off-by: Antoine Pelisse apeli...@gmail.com --- I'm sorry about this fix, it really seems bad, yet it's one step closer to warning-free clang compilation. It seems quite clear to me that it's a bug in clang. Which version of clang did you see this with? I don't get these warnings with clang 3.2. John -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 1/2] fix clang -Wconstant-conversion with bit fields
On Thu, Jan 17, 2013 at 12:08 AM, John Keeping j...@keeping.me.uk wrote: On Wed, Jan 16, 2013 at 11:47:22PM +0100, Antoine Pelisse wrote: clang incorrectly reports a constant conversion warning (implicit truncation to bit field) when using the flag = ~FLAG form, because ~FLAG needs to be truncated. Which version of clang did you see this with? I don't get these warnings with clang 3.2. Ubuntu clang version 3.0-6ubuntu3 (tags/RELEASE_30/final) (based on LLVM 3.0) It's good to know it's been fixed ! -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 1/2] fix clang -Wconstant-conversion with bit fields
So I guess we should drop this patch, it's probably not worth it, especially if it's been fixed already by clang. On Thu, Jan 17, 2013 at 12:09 AM, Antoine Pelisse apeli...@gmail.com wrote: On Thu, Jan 17, 2013 at 12:08 AM, John Keeping j...@keeping.me.uk wrote: On Wed, Jan 16, 2013 at 11:47:22PM +0100, Antoine Pelisse wrote: clang incorrectly reports a constant conversion warning (implicit truncation to bit field) when using the flag = ~FLAG form, because ~FLAG needs to be truncated. Which version of clang did you see this with? I don't get these warnings with clang 3.2. Ubuntu clang version 3.0-6ubuntu3 (tags/RELEASE_30/final) (based on LLVM 3.0) It's good to know it's been fixed ! -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 1/2] fix clang -Wconstant-conversion with bit fields
Antoine Pelisse apeli...@gmail.com writes: clang incorrectly reports a constant conversion warning (implicit truncation to bit field) when using the flag = ~FLAG form, because ~FLAG needs to be truncated. Convert this form to flag = flag ~FLAG fixes the issue as the right operand now fits into the bit field. If the clang incorrectly reports is already recognised by clang folks as a bug to be fixed in clang, I'd rather not to take this patch. I do not think it is reasonable to expect people to remember that they have to write flags = ~TO_DROP in a longhand whenever they are adding new code that needs to do bit-fields, so even if this patch makes clang silent for the _current_ code, it will not stay that way. Something like #define FLIP_BIT_CLR(fld,bit) do { \ typeof(fld) *x = (fld); \ *x = *x (~(bit)); \ } while (0) may be more palapable but not by a large margin. Yuck. -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 1/2] fix clang -Wconstant-conversion with bit fields
Junio C Hamano gits...@pobox.com writes: Antoine Pelisse apeli...@gmail.com writes: clang incorrectly reports a constant conversion warning (implicit truncation to bit field) when using the flag = ~FLAG form, because ~FLAG needs to be truncated. Convert this form to flag = flag ~FLAG fixes the issue as the right operand now fits into the bit field. If the clang incorrectly reports is already recognised by clang folks as a bug to be fixed in clang, I'd rather not to take this patch. I do not think it is reasonable to expect people to remember that they have to write flags = ~TO_DROP in a longhand whenever they are adding new code that needs to do bit-fields, so even if this patch makes clang silent for the _current_ code, it will not stay that way. Something like #define FLIP_BIT_CLR(fld,bit) do { \ typeof(fld) *x = (fld); \ *x = *x (~(bit)); \ } while (0) may be more palapable but not by a large margin. Yuck. Double yuck. I meant palatable. In any case, I see somebody reports that more recent clang does not have this bug in the near-by message, so let's forget about this issue. Thanks. -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html