[comp.lang.c++] C++ inline bug ==> stream bug

shapiro@inria.UUCP (Marc Shapiro) (04/22/87)

This bug is notified by Philippe Gautron (mcvax!inria!corto!gautron):

 Subject: C++ bug (and stream bug)
    Bjarne,

    Is the follow bug known?

---
    struct streambuf{
        overflow ( int c = -1 );
        inline sputc ( int c = -1 ){
            int i = c & 0377;
        }
        inline another_sputc ( int c = 0 ){
            int i = c & 0377;
        }
    };

    streambuf::overflow( int c ){
        sputc( c );
        another_sputc( c );
    }
----

 outlined:

    int _streambuf_overflow (this , c ) struct streambuf *this ; int c ;
    {
        int sputc_streambuf ;
        int another_sputc_streambuf ;

        sputc_streambuf = 255 ;  // here is the bug
        another_sputc_streambuf = (c & 0377 ) ;
    }

----

    A negatif default value overwrites argument to inline (-1 as well as -2 ..)
    There is this bug in the stream library. Can you reply me the solution?

    Sincerly
    Philippe

-- 

Marc Shapiro
INRIA Bat. 11
B.P. 105
78153 Le Chesnay Cedex
		France
tel. +33 (1) 39-63-53-25
uucp: seismo!mcvax!inria!shapiro
or:   shapiro@inria.inria.fr