Bug 30099 - misleading warning when && operator paired with a constant - is it operator precedence?
Summary: misleading warning when && operator paired with a constant - is it operator p...
Status: RESOLVED NOTABUG
Alias: None
Product: cairo
Classification: Unclassified
Component: general (show other bugs)
Version: 1.10.1
Hardware: ARM Linux (All)
: medium normal
Assignee: Carl Worth
QA Contact: cairo-bugs mailing list
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-09-09 03:17 UTC by Alexander Stohr
Modified: 2010-09-09 03:22 UTC (History)
1 user (show)

See Also:
i915 platform:
i915 features:


Attachments

Description Alexander Stohr 2010-09-09 03:17:06 UTC
gcc --version
gcc (GCC) 4.3.1
Copyright (C) 2008 Free Software Foundation, Inc.

found in package cairo-1.9.14 and file test/cairo-test.c with critical line 1597:
  if (ctx->thread == 0 && ! RUNNING_ON_VALGRIND)

build outputs:
"warning: logical '&&' with non-zero constant will always evaluate as true"

from the used setup the VALGRIND macro is assumed to have a true value.
(a code checker would probably suggest using round braces around the "==" part.
the used default project tuning of gcc does not raise a warning on operator precedence.)

whats the problem?
a) if you use && with a constant and something else
then your result will always either be false (const=false) or something else (const=true).
there is no case for the compiler seeing this as fixed to true.
b) maybe its unintended operator precedence that makes the case behave strangely
Comment 1 Chris Wilson 2010-09-09 03:22:51 UTC
An overzealous warning; just warning that the (&& ! RUNNING_ON_VALGRIND) is redundant and compiled out.


Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.