c++ - warning 11 is missing or depends on unrelated error
- Steve Strand (20/20) Feb 20 2003 struct A {
- Walter (1/1) Feb 20 2003 I've logged the bug, thanks. -Walter
struct A { int a; A(int j) : a(j) {}; }; // non-const reference argument announces intention to change argument void f(A& j) {j.a= 0;} A sum(A j, A k) {return A(j.a+k.a);} main() { j= 1; // error: undefined identifier (any error will do) f( A(1) ); // should get warning 11 but don't f( sum(A(2),A(3)) ); // should get warning 11 but don't unless prior error } The last two lines in main() both deserve warning 11 "non-const reference initialized to temporary". When I compile the program only the last line gets the warning. If I fix the error on the first line of main then neither line gets a warning. This is with version 8.32.17n of the compiler and all compiler flags defaulted. Steve Strand
Feb 20 2003