[LLVMbugs] [Bug 19468] New: False positive: condition with const enum evaluates to true and then to false

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Thu Apr 17 10:02:33 PDT 2014


http://llvm.org/bugs/show_bug.cgi?id=19468

            Bug ID: 19468
           Summary: False positive: condition with const enum evaluates to
                    true and then to false
           Product: clang
           Version: 3.4
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: Static Analyzer
          Assignee: kremenek at apple.com
          Reporter: pspacek at redhat.com
                CC: llvmbugs at cs.uiuc.edu
    Classification: Unclassified

Created attachment 12392
  --> http://llvm.org/bugs/attachment.cgi?id=12392&action=edit
scan-build results

Version:
clang-analyzer-3.4-6.fc20.noarch
clang-3.4-6.fc20.x86_64


Problem:
Analyzer claims that the condition on the same variable evaluates to two
different results:  

Please note that variable in question is "const isc_boolean_t new_zone".

1901    static isc_result_t ATTR_NONNULLS ATTR_CHECKRESULT
1902    zone_sync_apex(ldap_instance_t *inst, ldap_entry_t *entry, dns_name_t
name,
1903    sync_state_t sync_state, const isc_boolean_t new_zone,
1904    dns_db_t *ldapdb, dns_db_t *rbtdb, dns_dbversion_t *version,
1905    dns_diff_t *diff, isc_uint32_t *new_serial,
1906    isc_boolean_t *ldap_writeback) {
...
1935    if (new_zone == ISC_FALSE)
    Assuming 'new_zone' is not equal to isc_boolean_false    
    Taking false branch    
1936        CHECK(dns_db_getsoaserial(rbtdb, version, &curr_serial));
1937    
1938    /* Detect if SOA serial is affected by the update or not.
1939    * Always bump serial in case of re-synchronization. */
1940    CHECK(diff_analyze_serial(diff, &soa_tuple, &data_changed));
1941    if (new_zone == ISC_TRUE || data_changed == ISC_TRUE ||
    Assuming 'new_zone' is not equal to isc_boolean_true

It is interesting that the problem disappears if I change

1935    if (new_zone == ISC_FALSE)
to
1935    if (new_zone != ISC_TRUE)

Relevant definitions are:

typedef enum { isc_boolean_false = 0, isc_boolean_true = 1 } isc_boolean_t;

#define ISC_FALSE isc_boolean_false
#define ISC_TRUE isc_boolean_true
#define ISC_TF(x) ((x) ? ISC_TRUE : ISC_FALSE)

Maybe the analyzer assumes that the value can be something else than 0 or 1?

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20140417/454bbf53/attachment.html>


More information about the llvm-bugs mailing list