This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Bug in strstream ?
- To: gcc-bugs at gcc dot gnu dot org
- Subject: Bug in strstream ?
- From: Sven Eschenberg <eschenb at cs dot uni-frankfurt dot de>
- Date: Wed, 11 Apr 2001 03:15:18 +0200
- Reply-To: Sven Eschenberg <eschenb at cs dot uni-frankfurt dot de>
Hello GCC-Dev-Folks,
I got a small Programm, which outputs somethign really unexpected:
I am trying to attach all the info you might need:
uname -a: Linux orion 2.2.17 #5 Tue Nov 14 10:52:33 MET 2000 i686 unknown
Compilation:
orion > g++ -save-temps -v -Wall strtestb.cc -o strtestb
Reading specs from /usr/lib/gcc-lib/i486-suse-linux/2.95.2/specs
gcc version 2.95.2 19991024 (release)
/usr/lib/gcc-lib/i486-suse-linux/2.95.2/cpp -lang-c++ -v -D__GNUC__=2 -D__GNUG__=2 -D__GNUC_MINOR__=95 -D__cplusplus -D__ELF__ -Dunix -D__i386__ -Dlinux -D__ELF__ -D__unix__ -D__i386__ -D__linux__ -D__unix -D__linux -Asystem(posix) -D__EXCEPTIONS -Wall -Acpu(i386) -Amachine(i386) -Di386 -D__i386 -D__i386__ -Di486 -D__i486 -D__i486__ strtestb.cc strtestb.ii
GNU CPP version 2.95.2 19991024 (release) (i386 Linux/ELF)
#include "..." search starts here:
#include <...> search starts here:
/usr/include/g++
/usr/local/include
/usr/lib/gcc-lib/i486-suse-linux/2.95.2/include
/usr/include
End of search list.
The following default directories have been omitted from the search path:
/usr/lib/gcc-lib/i486-suse-linux/2.95.2/../../../../i486-suse-linux/include
End of omitted list.
/usr/lib/gcc-lib/i486-suse-linux/2.95.2/cc1plus strtestb.ii -quiet -dumpbase strtestb.cc -Wall -version -o strtestb.s
GNU C++ version 2.95.2 19991024 (release) (i486-suse-linux) compiled by GNU C version 2.95.2 19991024 (release).
/usr/i486-suse-linux/bin/as -V -Qy -o strtestb.o strtestb.s
GNU assembler version 2.9.5 (i486-suse-linux) using BFD version 2.9.5.0.24
/usr/lib/gcc-lib/i486-suse-linux/2.95.2/collect2 -m elf_i386 -dynamic-linker /lib/ld-linux.so.2 -o strtestb /usr/lib/crt1.o /usr/lib/crti.o /usr/lib/gcc-lib/i486-suse-linux/2.95.2/crtbegin.o -L/usr/lib/gcc-lib/i486-suse-linux/2.95.2 -L/usr/i486-suse-linux/lib strtestb.o -lstdc++ -lm -lgcc -lc -lgcc /usr/lib/gcc-lib/i486-suse-linux/2.95.2/crtend.o /usr/lib/crtn.o
Output of compiled programm:
orion > strtestb
25880
25880@ÿÿÿÿ
12
I actually expect it to output:
PID
PID
length of PID as string (in the example 5)
Here's the source, the Preprocessed .ii is attached:
#include <string>
#include <time.h>
#include <unistd.h>
#include <strstream>
#include <stdio.h>
int main(){
struct tm* test=0;
string istr;
time_t LogTime;
pid_t i;
ostrstream dummy;
i = ::getpid();
dummy << i;
istr=dummy.str();
cout << dummy.str() << endl;
LogTime=::time(NULL); //Get Secs since Epoch
test=::localtime(&LogTime);//comment out this line for expected behavior
i = ::getpid();
ostrstream dummy2;
dummy2 << i;
istr=dummy2.str();
cout << istr << endl;
cout << istr.length() << endl;
return 0;
}
I wonder if it is my fault, screwing things up, the funny thing is, on
older gcc versions this compiles fine, wasn't able to test it on too
many different versions.
The Problem was reproduceable on an alpha machine too ... it might be
a problem in stdlibc++, I really don't know, just wanted to let you
folks know. Maybe the problem is resolved in newer versions. I wasn't
able to post it 2 months ago, when I hit on it ...
--
Regards,
Sven mailto:eschenb@cs.uni-frankfurt.de
strtestb.ii.gz