Fixed a bug [1].
ExistingInit was a null pointer, so I added a check.
After this change, I could get similar result as GCC [2].
[1] http://bugs.llvm.org/show_bug.cgi?id=32280
[2] https://pastebin.com/mNFKDubm
Differential D31591
Fix a bug which access nullptr and cause segmentation fault yamaguchi on Apr 2 2017, 9:56 PM. Authored by
Details
Fixed a bug [1]. [1] http://bugs.llvm.org/show_bug.cgi?id=32280
Diff Detail Event TimelineComment Actions Please fix these things:
~/llvm/build/bin/clang -cc1 test.c test.c:41:6: error: field designator 'dog' does not refer to any field in type 'struct_0' .dog = 0x00000000, ^ warning: initializer overrides prior initialization of this subobject The warning: is obviously missing the note: Previous initialization here and doesn't make a lot of sense that way, so let's skip the whole thing altogether. We should check if ExistingInit is a nullptr before we start printing the warning (which is a few lines above the note printing).
Comment Actions Moved if (ExistingInit) above, so that warning will not printed without notes, and fixed indents.
Comment Actions Is this a minimal test case that can produce the issue? It'd be awesome if you can reduce it. sema-segvcheck.c is not a good name for this test because that name can be used for any crash bug. You want to see other files in the same directory to name your file so that it's consistent with other files. If you don't come up with a name, I'd name it pr32280.c. Comment Actions @yamaguchi, I'd support Akira's comment. Could you place the minimal test example in the suggested file? Comment Actions I've been trying to minimal the testcase, add comments to describe what it is testing, and fix styles of the testcase properly. |