warning: equality comparison with extraneous parentheses [-Wparentheses-equality] with clang

901 views
Skip to first unread message

Marc Abramowitz

unread,
Jul 15, 2013, 5:23:36 PM7/15/13
to cython...@googlegroups.com
I noticed that certain Cython code will cause Cython to emit C code with extra parentheses (probably trying to err on the side of being conservative and correct?) that the clang compiler will warn about (gcc doesn't emit this warning as far as I can tell). Example:

$ cat foo.pyx
def f(int a):
  return 1 if a == 1 else 2

$ cython foo.pyx && clang -I/System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 -c foo.c
foo.c:505:18: warning: equality comparison with extraneous parentheses [-Wparentheses-equality]
  if ((__pyx_v_a == 1)) {
       ~~~~~~~~~~^~~~
foo.c:505:18: note: remove extraneous parentheses around the comparison to silence this warning
  if ((__pyx_v_a == 1)) {
      ~          ^   ~
foo.c:505:18: note: use '=' to turn this equality comparison into an assignment
  if ((__pyx_v_a == 1)) {
                 ^~
                 =
1 warning generated.

Maybe it's not realistic for Cython to try to placate every compiler? If this were something easy to fix, I might take a stab at it, but if it's a long rabbit hole, then I'll avoid it. :-)

Marc
Reply all
Reply to author
Forward
0 new messages