Skip to content

Commit

Permalink
Fix undefined behaviour in C code problem
Browse files Browse the repository at this point in the history
Without the return, this code would core dump, depending
on compiler version. The compiler was generating a warning
too about the missing return.

Part of eclipse-cdt#816
  • Loading branch information
jonahgraham committed Dec 28, 2024
1 parent 908d854 commit 9a738ed
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,7 @@ int testUpdateIssue() {
/* testUpdateIssue_init */
a = 1.22;
a = 1.22; // this redundant line is here to ensure 3 steps after running to this func leaves locals visible
return 0;
}

int testUpdateIssue2() {
Expand All @@ -262,7 +263,8 @@ int testUpdateIssue2() {
z.d = 1.0;
/* testUpdateIssue2_init */
z.d = 1.22;
z.d = 1.22; // this redundant line is here to ensure 3 steps after running to this func leaves locals visible
z.d = 1.22; // this redundant line is here to ensure 3 steps after running to this func leaves locals visible
return 0;
}

int testConcurrentReadAndUpdateChild() {
Expand All @@ -273,6 +275,7 @@ int testConcurrentReadAndUpdateChild() {
z.d = 1;
/* testConcurrentReadAndUpdateChild_init */
z.d = 2;
return 0;
}

int testConcurrentUpdateOutOfScopeChildThenParent1() {
Expand All @@ -283,6 +286,7 @@ int testConcurrentUpdateOutOfScopeChildThenParent1() {
z.d = 1;
/* testConcurrentUpdateOutOfScopeChildThenParent1_init */
z.d = 1; // this redundant line is here to ensure 2 steps after running to this func leaves locals visible
return 0;
}

int testConcurrentUpdateOutOfScopeChildThenParent2() {
Expand All @@ -293,11 +297,13 @@ int testConcurrentUpdateOutOfScopeChildThenParent2() {
z.d = 2;
/* testConcurrentUpdateOutOfScopeChildThenParent2_init */
z.d = 2; // this redundant line is here to ensure 2 steps after running to this func leaves locals visible
return 0;
}

int testConcurrentUpdateOutOfScopeChildThenParent() {
testConcurrentUpdateOutOfScopeChildThenParent1();
testConcurrentUpdateOutOfScopeChildThenParent2();
return 0;
}

int testUpdateOfPointer() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ int laterLineNotHitTest() {
int laterLineDifferentFileTest() {
int b = 0;
value(); // LATER_LINE_DIFFERENT_FILE_LINE
return 0;
}

int differentFileTest() {
Expand Down

0 comments on commit 9a738ed

Please sign in to comment.