This is the mail archive of the gdb-prs@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/11993] New: Strange behaviour - invalid information about objects.


// Author: Dmitriy Igrishin
// Date: 2010/09/08
// This example demonstrates the strange behaviour of GDB.
// Executable itself runs as expected.
// Tested with:
//   g++ (Ubuntu 4.4.1-4ubuntu9) 4.4.1
//   GNU gdb (GDB) 7.0-ubuntu
// Compile command:
//   g++ -Wall -std=c++98 -pedantic -g main.cpp -o main

#include <iostream>
#include <string>

template<class T>
class A {
public:
  static const std::string f(const T& value);
};

template<class T> const std::string A<T>::f(const T& value)
{
  std::string s = "Dima";       // look at the s or s.size() from GDB ;-)
                                // on my machine printing s.size() here
                                // cause SIGSEGV.
  std::cerr << "A<T>::f(): s = \"" << s << "\""
            << " s.size() = " << s.size() << std::endl;

  return s;                     // remove this return and s (and s.size())
                                // from GDB will be correct!
}

template<> const std::string A<int>::f(const int& value)
{
  std::string s = "Alex";       // look at the s or s.size() from GDB ;-)
                                // on my machine printing s.size() cause
                                // unpredicable result.
  std::cerr << "A<int>::f(): s = \"" << s << "\""
            << " s.size() = " << s.size() << std::endl;

  return s;                     // remove this return and s (and s.size())
                                // from GDB will be correct!
}

int main(int argc, char* argv[])
{
  A<int>::f(1);
  A<double>::f(2.3);
}

-- 
           Summary: Strange behaviour - invalid information about objects.
           Product: gdb
           Version: 7.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: c++
        AssignedTo: unassigned at sourceware dot org
        ReportedBy: dmitigr at gmail dot com
                CC: gdb-prs at sourceware dot org


http://sourceware.org/bugzilla/show_bug.cgi?id=11993

------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]