1
0
mirror of https://gitlab.com/camelot/kickc.git synced 2024-06-03 07:29:37 +00:00

Added example program demonstrating NPE when removing empty method.

This commit is contained in:
jespergravgaard 2021-11-21 19:02:58 +01:00
parent 279dd28fb0
commit b441863aa1
2 changed files with 26 additions and 0 deletions

View File

@ -9,6 +9,12 @@ import java.io.IOException;
*/
public class TestProgramsFast extends TestPrograms {
/* Fix problem where removing empty method can cause NPE (because a local variable in the method is still used)
@Test
public void testStructOptimizeProblem() throws IOException {
compileAndCompare("struct-optimize-problem.c",log().verboseSSAOptimize());
}
*/
@Test
public void testTmpZpProblem() throws IOException {

View File

@ -0,0 +1,20 @@
// Re-create problem where removing empty method can cause NPE (because a local variable in the method is still used)
struct line_t {
char buf[10];
char pos;
};
struct line_t lines[10];
char *lined_line(struct line_t *l) {
return (l->buf);
}
void main() {
struct line_t* line = lines;
for(char i=0;i<10;i++) {
char* buf = lined_line(line);
*buf = 'a';
line++;
}
}