Non-deterministic diagnostics for -Wuninitialized.

Hello.

We are obtaining non-deterministic diagnostic ordering when running clang with -Wuninitialized on the following testcase

$ cat bug.c
void foo(int a) {
   int b, c;
   a = b;
   a = c;
}

$ clang -Wuninitialized -fsyntax-only bug.c 2> diag; md5sum diag
77a113d00be8eae91ea079159fcbeb22 diag
$ clang -Wuninitialized -fsyntax-only bug.c 2> diag; md5sum diag
aebb2b8d1cf3f47e82c8c43634d49bc8 diag

Is this a known issue?

Enea.

Hi Enea,

Hello.

We are obtaining non-deterministic diagnostic ordering when running clang
with -Wuninitialized on the following testcase

$ cat bug.c
void foo(int a) {
  int b, c;
  a = b;
  a = c;
}

$ clang -Wuninitialized -fsyntax-only bug.c 2> diag; md5sum diag
77a113d00be8eae91ea079159fcbeb22 diag
$ clang -Wuninitialized -fsyntax-only bug.c 2> diag; md5sum diag
aebb2b8d1cf3f47e82c8c43634d49bc8 diag

Which version of clang are you using? I got the same md5sum (different
from both of yours) ten times in a row with

$ clang -v
clang version 3.3 (trunk 171717)
Target: x86_64-unknown-linux-gnu
Thread model: posix

Csaba

$ clang -v
clang version 3.3 (trunk 171957)
Target: x86_64-unknown-linux-gnu
Thread model: posix

(built in debug mode).

$ clang -Wuninitialized -fsyntax-only bug.c 2> diag; md5sum diag
aebb2b8d1cf3f47e82c8c43634d49bc8 diag
$ clang -Wuninitialized -fsyntax-only bug.c 2> diag; md5sum diag
aebb2b8d1cf3f47e82c8c43634d49bc8 diag
$ clang -Wuninitialized -fsyntax-only bug.c 2> diag; md5sum diag
aebb2b8d1cf3f47e82c8c43634d49bc8 diag
$ clang -Wuninitialized -fsyntax-only bug.c 2> diag; md5sum diag
77a113d00be8eae91ea079159fcbeb22 diag
$ clang -Wuninitialized -fsyntax-only bug.c 2> diag; md5sum diag
77a113d00be8eae91ea079159fcbeb22 diag
$ clang -Wuninitialized -fsyntax-only bug.c 2> diag; md5sum diag
aebb2b8d1cf3f47e82c8c43634d49bc8 diag
[...]

Enea.

It may be something the debug mode prints (my clang is Release+Asserts).

There seems to be two different outputs. Perhaps if you showed them
instead of the md5sum, it would be easier to spot the difference.

Csaba

The difference is just the order of the two diagnostics.

These diagnostics are *not* produced by the static analyzer. These are compiler warnings.

Also, the CFG iterators are deterministic. The list of basic blocks is just a vector.

Hi Enea,

Can file a bugzilla PR for this and assign it to me?

Cheers,
Ted

Here it is: http://llvm.org/bugs/show_bug.cgi?id=14901

Regards,
Enea.

Thanks!

Ping.

Can someone review the patch proposed for this bugzilla report?
(http://llvm.org/bugs/attachment.cgi?id=9892)

Is it OK to commit it?

Thanks,
Enea.

Ping.

Can someone review the patch proposed for this bugzilla report?
(http://llvm.org/bugs/attachment.cgi?id=9892)

Is it OK to commit it?

This needs a test. A simple test using FileCheck to check the diagnostic order would be fine.

Committed in r175289.

Enea.

Sorry I completely missed this. The patch looks great. Thanks for doing this.