www.digitalmars.com Home | Search | C & C++ | D | DMDScript | News Groups | index | prev | next
Archives

D Programming
D
D.gnu
digitalmars.D
digitalmars.D.bugs
digitalmars.D.dtl
digitalmars.D.dwt
digitalmars.D.announce
digitalmars.D.learn
digitalmars.D.debugger

C/C++ Programming
c++
c++.announce
c++.atl
c++.beta
c++.chat
c++.command-line
c++.dos
c++.dos.16-bits
c++.dos.32-bits
c++.idde
c++.mfc
c++.rtl
c++.stl
c++.stl.hp
c++.stl.port
c++.stl.sgi
c++.stlsoft
c++.windows
c++.windows.16-bits
c++.windows.32-bits
c++.wxwindows

digitalmars.empire
digitalmars.DMDScript

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

↑ ↓ ← "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);}

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