[cfe-dev] Static Analysis Warning?

Bill Wendling wendling at apple.com
Fri Aug 27 14:24:34 PDT 2010


Consider this code:

#include <stdio.h>

enum Foo {
  VAL1,
  VAL2
};

int main (int argc, const char * argv[]) {
    // insert code here...
    printf("Hello, World! %d\n", argc == 42 ? VAL1 : VAL1);
    return 0;
}

When I run the static analyzer on it, it doesn't warn. But the coder might not have meant for both values of the ?: operator to be the same. Do you think it's worth a static analyzer warning?

-bw





More information about the cfe-dev mailing list