aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoman Lebedev <lebedev.ri@gmail.com>2019-10-02 16:37:13 +0000
committerRoman Lebedev <lebedev.ri@gmail.com>2019-10-02 16:37:13 +0000
commit59646304d14c47ba4003d7c1aff537ad0034d037 (patch)
tree92721ffd7a251454a44dda9509503876e9f71fe9
parent8f3667acb3a6438c8088302b94a8bdbf7662623f (diff)
downloadtest-suite-59646304d14c47ba4003d7c1aff537ad0034d037.tar.gz
MultiSource/Applications/d: applying zero offset to null pointer is UB in C
Caught by https://reviews.llvm.org/D67122 Address of the zero-th element of an array is identical to the address of the array base pointer (&a[0] == a), so let's just not apply zero offset. llvm-test-suite/MultiSource/Applications/d/parse.c:1588:20: runtime error: applying zero offset to null pointer #0 0x251be9 in commit_tree (/builddirs/build-test-suite-old/MultiSource/Applications/d/make_dparser+0x251be9) #1 0x2515b4 in commit_tree (/builddirs/build-test-suite-old/MultiSource/Applications/d/make_dparser+0x2515b4) #2 0x2515b4 in commit_tree (/builddirs/build-test-suite-old/MultiSource/Applications/d/make_dparser+0x2515b4) #3 0x2515b4 in commit_tree (/builddirs/build-test-suite-old/MultiSource/Applications/d/make_dparser+0x2515b4) #4 0x2515b4 in commit_tree (/builddirs/build-test-suite-old/MultiSource/Applications/d/make_dparser+0x2515b4) #5 0x2515b4 in commit_tree (/builddirs/build-test-suite-old/MultiSource/Applications/d/make_dparser+0x2515b4) #6 0x2515b4 in commit_tree (/builddirs/build-test-suite-old/MultiSource/Applications/d/make_dparser+0x2515b4) #7 0x2515b4 in commit_tree (/builddirs/build-test-suite-old/MultiSource/Applications/d/make_dparser+0x2515b4) #8 0x2515b4 in commit_tree (/builddirs/build-test-suite-old/MultiSource/Applications/d/make_dparser+0x2515b4) #9 0x2515b4 in commit_tree (/builddirs/build-test-suite-old/MultiSource/Applications/d/make_dparser+0x2515b4) #10 0x2515b4 in commit_tree (/builddirs/build-test-suite-old/MultiSource/Applications/d/make_dparser+0x2515b4) #11 0x2515b4 in commit_tree (/builddirs/build-test-suite-old/MultiSource/Applications/d/make_dparser+0x2515b4) #12 0x2515b4 in commit_tree (/builddirs/build-test-suite-old/MultiSource/Applications/d/make_dparser+0x2515b4) #13 0x253e87 in commit_stack (/builddirs/build-test-suite-old/MultiSource/Applications/d/make_dparser+0x253e87) #14 0x253e44 in commit_stack (/builddirs/build-test-suite-old/MultiSource/Applications/d/make_dparser+0x253e44) #15 0x250ef1 in exhaustive_parse (/builddirs/build-test-suite-old/MultiSource/Applications/d/make_dparser+0x250ef1) #16 0x24facd in dparse (/builddirs/build-test-suite-old/MultiSource/Applications/d/make_dparser+0x24facd) #17 0x2441b0 in parse_grammar (/builddirs/build-test-suite-old/MultiSource/Applications/d/make_dparser+0x2441b0) #18 0x23a270 in main (/builddirs/build-test-suite-old/MultiSource/Applications/d/make_dparser+0x23a270) #19 0x7fac77faebba in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x26bba) #20 0x21aeb9 in _start (/builddirs/build-test-suite-old/MultiSource/Applications/d/make_dparser+0x21aeb9) SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior /repositories/llvm-test-suite/MultiSource/Applications/d/parse.c:1588:20 in git-svn-id: https://llvm.org/svn/llvm-project/test-suite/trunk@373486 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--MultiSource/Applications/d/parse.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/MultiSource/Applications/d/parse.c b/MultiSource/Applications/d/parse.c
index 951dd8fb..11d1eb5c 100644
--- a/MultiSource/Applications/d/parse.c
+++ b/MultiSource/Applications/d/parse.c
@@ -1585,7 +1585,7 @@ commit_tree(Parser *p, PNode *pn) {
}
if (pn->reduction && pn->reduction->final_code)
pn->reduction->final_code(
- pn, (void**)&pn->children.v[0], pn->children.n,
+ pn, (void**)pn->children.v, pn->children.n,
(int)&((PNode*)(NULL))->parse_node, (D_Parser*)p);
if (pn->evaluated) {
if (!p->user.save_parse_tree && !internal)