Compiler construction 控制流图优势

Compiler construction 控制流图优势,compiler-construction,control-flow-graph,Compiler Construction,Control Flow Graph,我正在为一个个人项目学习编译器,为此我查阅了英国一所大学的一些论文。我偶然发现的一个问题如下: Draw a CFG which contains a definition followed by a use of a variable x, but in which the use of x is not dominated by any definitions of x. 这怎么可能?如果使用不受定义支配,这意味着使用x的块将有x超出范围?我看得不对吗 说我们有 1:int y=2 2:

我正在为一个个人项目学习编译器,为此我查阅了英国一所大学的一些论文。我偶然发现的一个问题如下:

Draw a CFG which contains a definition followed by a use of a variable x, but in 
which the use of x is not dominated by any definitions of x.
这怎么可能?如果使用不受定义支配,这意味着使用x的块将有x超出范围?我看得不对吗

说我们有

1:int y=2

2:如果(y>0)

3:intx=5

4:else x++


在这种情况下,x的使用不受定义的支配,但x不在范围内,因此不能使用。我不明白…

请记住,x的定义及其声明是两件不同的事情,范围界定只关心声明。考虑以下事项:

int x;
if (user_input_integer() == 0) {
    x = 0;
} else {
    x = 1;
}
x++;

请记住,x的定义及其声明是两件不同的事情,范围界定只关心声明。考虑以下事项:

int x;
if (user_input_integer() == 0) {
    x = 0;
} else {
    x = 1;
}
x++;