www.digitalmars.com         C & C++   DMDScript  

c++ - warning 11 is missing or depends on unrelated error

reply "Steve Strand" <snstrand attbi.com> writes:
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);}

    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
parent "Walter" <walter digitalmars.com> writes:
I've logged the bug, thanks. -Walter
Feb 20 2003