Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 12 Sep 2001 16:03:31 EST
From:      Andrea Venturoli <ml.ventu@flashnet.it>
To:        freebsd-questions@FreeBSD.ORG
Subject:   Does g++/gdb work???
Message-ID:  <200109121403.f8CE3U401986@relay.flashnet.it>

next in thread | raw e-mail | index | archive | help
Hello.  
  
I'm trying to compile some C++ projects of mine on FreeBSD 4.3.  
The problem is I get very strange behaviours, some of which are listed below:  
  
_ I declare main as "int main(int argv,char**argv)"; now if put a breakpoint on main I    
sometime get trash in argv and argc; if I continue the execution, however, it seems that the    
two values are correct, since the program behaves, possibly indicating that gdb shows them    
wrong; this problem disappears if I remove a try/catch block from inside main. I don't see    
any reason why modifing something *inside* main should influence the program behaviour when    
main is called!  
  
_ I have a class ON_BinaryStream which is derived from class ON_BinaryArchive; I put a    
breakpoint in one of ON_BinaryArchive method (on a ON_BinaryStream object): now, if I "p    
this" the result is obvioulsy (ON_BinaryArchive*) 0xsomeaddress; if I "p    
(ON_BinaryStream*)this" I get the same address, but "p *this" and "p    
*((ON_BinaryArchive*)this)" show different values for the base class data members! Then "p    
*this" shows that _vptr$ is 0x0, and, in fact, the program generates a sigsev when a virtual    
method is called. I found no explanation for this, either.  
  
_ Another project uses "vector"s from the STL. Here the result are sometimes completely    
random. Inverting the order of some *totally unrelated* statements may cause the program to    
work or fail with gdb showing trash in the vector's data member. Again this is not normal,    
IMHO. I tried this on three different machines (a 486 with 4.3, a Pentium with 4.3 and a    
Duron with 4.2).  
  
These are only some of the strange things I witnessed.  
 
"gcc -v" tells "2.95.3 [FreeBSD] 20010315 (release)". 
 
I usually compile all of the projects above on an OS/2 machine with pgcc-2.95.2 and they    
work fine. So I tried installing the package pgcc-2.95.2 and use that, but the results are    
the same.  
  
Now, I can't believe C++ support is so buggy, I guess a lot of people must be using it and    
they would be complaining very loud. Am I missing something? Is there an upgrade path I must    
take? Anything that could enable me to work with C++ is appreciated.  
  
 Bye & Thanks  
	av.  
 




To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-questions" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200109121403.f8CE3U401986>