Showing arguments issue with g++ 4.1.2 and gdb

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi everyone,

Today, I get a problem with g++ 4.1.2 and gdb.

The version of g++ and gdb is :

Using built-in specs.
Target: i386-redhat-linux
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --enable-shared --enable-threads=posix --enable-checking=release --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-libgcj-multifile --enable-languages=c,c++,objc,obj-c++,java,fortran,ada --enable-java-awt=gtk --disable-dssi --enable-plugin --with-java-home=/usr/lib/jvm/java-1.4.2-gcj-1.4.2.0/jre --with-cpu=generic --host=i386-redhat-linux
Thread model: posix
gcc version 4.1.2 20080704 (Red Hat 4.1.2-44)

AND 

GNU gdb Fedora (6.8-27.el5)
Copyright (C) 2008 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "i386-redhat-linux-gnu".

The demo code is :

#include <iostream>
#include <string>
using namespace std;
bool test_string( string temp1 , string temp2 ){
        string a1 = temp1;
        string a2 = temp2;
        cout<< temp1 << temp2<<endl;
}
int main( int argc , char ** argv ){
        test_string("test1" , "test21");
        return 0;
}

I compiled it only with -g option.
>g++ ./temp.cpp -g

then I use gdb to trace it.
>gdb ./a.out
>b test_string
>r
>p temp1

$1 = {static npos = 4294967295, _M_dataplus = {<std::allocator<char>> = {<__gnu_cxx::new_allocator<char>> = {<No data fields>}, <No data fields>},
    _M_p = 0xbfba8bd8 ",▒\t▒??"}}
>p temp2
$2 = {static npos = 4294967295, _M_dataplus = {<std::allocator<char>> = {<__gnu_cxx::new_allocator<char>> = {<No data fields>}, <No data fields>},
    _M_p = 0xbfba8bd0 "\024▒\t▒e|"}}

but both variables "a1" and "a2" are valid when they ard evaluated from "temp1" and "temp2" and "cout<< temp1 << temp2<<endl;" also is right.

Then I test it with g++ 3.4.6, this time every thing is OK.

Is this issue caused by g++4.1.2 or gdb? 
Any opinions?

Thanks a lot !

- Miles Zhao


      ___________________________________________________________ 
  好玩贺卡等你发,邮箱贺卡全新上线! 
http://card.mail.cn.yahoo.com/


[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux