PCH bug, cont'd

Jon Salz jsalz@mit.edu
Tue Jan 28 21:01:00 GMT 2003


On Tue, 28 Jan 2003, Paolo Carlini wrote:

> > Another way to reproduce the PCH bug is to change '\n' to endl in the 
> > g++.dg/pch testsuite.
> 
> This is, unfortunately, a known issue: other/9274.
> 
> > The rather unusual way that this is written (who writes a separate '\n'
> > instead of an endl?)
> 
> This is _not_ at all obvious: endl outputs a newline _and_ additionally
> flushes the output buffer: for efficiency sake the indiscriminate use of
> endl is discouraged in any good book about the C++ standard library.

True!  I just meant that every "Hello, world" program I've ever seen uses 
endl, and that if you were going to write out a \n instead you'd just 
stick it in the string rather than writing out a separate \n.  No matter.

Anyway, it seems you can work around the bug, at least in this instance, 
by including a dummy function in the header file like so:

    inline void foo() { std::cerr << std::endl; }

I'm not nearly smart enough to find a real solution, which probably 
involves fixing a missing find_substitution somewhere...

- Jon



More information about the Gcc-bugs mailing list