Mail Archives: cygwin/1998/10/27/16:24:09
I want to report here what I suspect is a bug in g++. I've been trying to get
round this one for a couple of weeks now and I'm getting nowhere.
Background: I'm porting a program originally developed on Solaris using g++.
It compiles and run fine there. It crashed with a SEGV under gnu-win32
(running the latest stuff, B19.1 and latest egcs).
The code is a template, using VHMap. It contains a rather large class called
'Net' which contains the following template:
VHMap<String, NetFileOrder *> fileorder;
'NetFileOrder' is a fairly simple class. The code calls the following
routine:
void
Net::NewFileOrder(const String &sn, const String &ln,
int of, int s, int e, int l)
{
NetFileOrder *nfo = new NetFileOrder(sn, ln, of, s, e, l);
fileorder[nfo->ShortName()] = nfo; }
The call to 'new' returns a valid pointer. nfo->Shortname() returns a valid
string. The final line causes the SEGV.
After the call to Shortname(), the following machine code is generated:
movl %eax,-36(%ebp)
movl -32(%ebp),%ebx
movl 4(%ebx),%eax
movl (%eax),%eax
movl %eax,4(%ebx)
addl $32,%esp
movl 8(%ebp),%ebx
movl 260(%ebx),%edx
movl -36(%ebp),%ebx
pushl %ebx
movswl 32(%edx),%eax
movl 8(%ebp),%ebx
leal 252(%eax,%ebx),%eax
pushl %eax
movl 36(%edx),%eax
call *%eax
;; further instructions deleted
Quite a handful for an array assignment! The final call causes the
SEGV. eax contains garbage. Running the program in quick succession
gives you the same garbage in eax. After a machine reboot, it becomes
completely different garbage.
If you compile on Solaris, you get the following (native) code, which is
apparently equivalent to the above:
mov %o0,%o1
mov %l2,%o0
call ___vc__t5VHMap2Z6StringZP12NetFileOrderRC6String,0
which suggests that the win95 code is trying to call the code for the
[] operator, but is trying to do this in a very strange way, and is
getting it horribly wrong.
I would be very grateful for any suggestions - I'm stuck, and I've
invested a lot of time in this program. Is there anyone who can
explain what is going on here? I don't normally suspect compiler bugs,
but the above code is part of the C++ 'infastructure', and is
completely different from the Solaris equivalent, which runs fine. The
compiler does not complain about anything. Mumit has suggested using
the 'map' template instead, but this would require major surgery to
the code, and I don't really want to do that (it's not my code).
Many thanks in advance,
Albert
-
For help on using this list (especially unsubscribing), send a message to
"gnu-win32-request AT cygnus DOT com" with one line of text: "help".
- Raw text -