Why compilers provide different warnings for auto x = a; and auto x (a) ;?

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: , . (- ). , , (, , ). , , ?

+3
2

At/W4, Visual ++ 2013:

x.cpp(6) : warning C4101: 'y' : unreferenced local variable
x.cpp(5) : warning C4189: 'x' : local variable is initialized but not referenced

Visual ++ /W 4 ( , ). , , (, C4109 , ).

+3

++ "" "". , . , , , ++, , .

, , ( , "" ) , , .

, , . , , , ? , , ? ? .

0

All Articles