mirror of
https://gitlab.com/camelot/kickc.git
synced 2025-01-13 03:30:17 +00:00
Added example program demonstrating NPE when removing empty method.
This commit is contained in:
parent
279dd28fb0
commit
b441863aa1
@ -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 {
|
||||
|
20
src/test/kc/struct-optimize-problem.c
Normal file
20
src/test/kc/struct-optimize-problem.c
Normal 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++;
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user