Skip to contentSkip to conversation

configure: disable -Wxor-used-as-pow

PATCH In review Paolo Bonzini 2 participants 3 messages Jun 23, 2020

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 configure: disable -Wxor-used-as-pow

Clang being clang and adding more pointless warnings. In a hardware emulator there are going to be plenty of bitwise operations, and the chance of someone writing ^ for pow and not being caught is basically zero.

---
 configure | 1 +
 1 file changed, 1 insertion(+)
configure +1 -0
index 8d9435a0e0..d42f060ee7 100755
@@ -2062,6 +2062,7 @@ add_to nowarn_flags -Wno-string-plus-int
 add_to nowarn_flags -Wno-typedef-redefinition
 add_to nowarn_flags -Wno-tautological-type-limit-compare
 add_to nowarn_flags -Wno-psabi
+add_to nowarn_flags -Wno-xor-used-as-pow
 
 gcc_flags="$warn_flags $nowarn_flags"
 
Signature · 1 line
2.26.2
#1 lore raw
Quoted 4 lines · Paolo Bonzini

Clang being clang and adding more pointless warnings. In a hardware emulator there are going to be plenty of bitwise operations, and the chance of someone writing ^ for pow and not being caught is basically zero.

Did this warning actually fire?

My understanding (from a quick glance of https://reviews.llvm.org/D63423) is that it is supposed to catch instances of '2 ^ 16' where someone meant '1 << 16' instead of 18. I don't know if it is supposed to flag 'a ^ 16' (if it does, then it is indeed useless), or only when both lhs and rhs are constants and where lhs is 2 or 10, so my initial reaction is that without seeing an actual false positive, we are premature in disabling it.

Quoted 11 lines
---
  configure | 1 +
  1 file changed, 1 insertion(+)
configure +0 -0
index 8d9435a0e0..d42f060ee7 100755

configure add_to nowarn_flags -Wno-string-plus-int · line 2065

Quoted 4 lines
configure +1 -0
@@ -2062,6 +2062,7 @@ add_to nowarn_flags -Wno-string-plus-int
  add_to nowarn_flags -Wno-typedef-redefinition
  add_to nowarn_flags -Wno-tautological-type-limit-compare
  add_to nowarn_flags -Wno-psabi
+add_to nowarn_flags -Wno-xor-used-as-pow

Pre-existing, but is it worth ordering flag additions in alphabetical order (the three preceding lines are in the wrong order if so).

Signature · 3 lines
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3226
Virtualization:  qemu.org | libvirt.org
#2 lore raw
Quoted 8 lines · Eric Blake
Quoted 4 lines · Paolo Bonzini

Clang being clang and adding more pointless warnings.  In a hardware emulator there are going to be plenty of bitwise operations, and the chance of someone writing ^ for pow and not being caught is basically zero.

Did this warning actually fire?

Quoted 7 lines

My understanding (from a quick glance of
https://reviews.llvm.org/D63423) is that it is supposed to catch instances of '2 ^ 16' where someone meant '1 << 16' instead of 18.  I don't know if it is supposed to flag 'a ^ 16' (if it does, then it is indeed useless), or only when both lhs and rhs are constants and where lhs is 2 or 10, so my initial reaction is that without seeing an actual false positive, we are premature in disabling it.

There is an instance of 2 ^ 20.

But it's actually a bug. Objection (and faith in humanity) retracted.

Paolo