The code is simple:
class AAA {};
AAA a;
int main() {
AAA x = a;
AAA y(a);
}
For g ++ 4.8 with, -std=c++11 -Wallit gives a warning only for the first line:
warning: the variable 'x' is set but not used [-Wunused-but-set-variable]
For vc12 with, /Za /W3it gives a warning only for the second line:
warning C4101: 'y': local variable without references
Why do compilers handle code differently? It seems that g ++ considers yit to be used , and vc considers xit to be used . What is the compiler logic behind this?
EDIT: , . (- ). , , (, , ). , , ?