This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
stream bug with "0xBlabla" strings in internal mode
- To: <gcc-bugs at gcc dot gnu dot org>
- Subject: stream bug with "0xBlabla" strings in internal mode
- From: Samuel Krempp <krempp at cmla dot ens-cachan dot fr>
- Date: Thu, 12 Jul 2001 00:59:20 +0200 (CEST)
The bug was reproduced with the following g++ :
gcc version 3.1 20010624 (experimental) - cvs
gcc version 3.1 20010707 (experimental) - cvs
gcc version 3.0 20010402 (Debian prerelease)
i686-pc-linux-gnu
and is not present in
gcc version 2.95.4 20010319 (Debian prerelease)
With the faulty compilers, the resulting string looks like :
Trap!ZZZÜø
(the 2 last chars vary, clearly comig from improper memory accesses)
hth,
--
Sam
#include <cassert>
#include <iostream>
#include <sstream>
int main(){
using namespace std;
stringstream oss;
oss.setf(std::ostream::internal, std::ostream::adjustfield);
oss.width(10);
oss.fill('Z');
oss << "0xTrap!";
cout << oss.str() << endl;
assert( oss.str() == "ZZZ0xTrap!" );
}