📄 outofbound.mj
字号:
/**
* This program is used to test whether your compiler can find out
* the out-of-bound operations of array. For those operations that
* can't be checked out at compile-time, your compiler should
* generate codes to check them at runtime.
* The following program is wrong. Your compiler should find out the
* errors as many as possible. And it's better to point out the exact
* positions of the errors and output useful information.
*/
class Program {
static void main() {
int[10] array;
array[-1] = -1; // ERROR: out of the lower bound. This error
// should be checked out at compile-time.
array[10] = 10; // ERROR: out of the upper bound. This error
// should be checked out at compile-time.
int i = -1;
// ERROR: There are illegal array accesses that is out of bound
// in the following loop. If your compiler can't check out them,
// be sure they can be checked out at runtime before the crash.
while (i<=10) {
array[i] = i;
}
return;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -