This is the mail archive of the
gdb-prs@sourceware.org
mailing list for the GDB project.
[Bug c++/11993] New: Strange behaviour - invalid information about objects.
- From: "dmitigr at gmail dot com" <sourceware-bugzilla at sourceware dot org>
- To: gdb-prs at sourceware dot org
- Date: 8 Sep 2010 18:00:40 -0000
- Subject: [Bug c++/11993] New: Strange behaviour - invalid information about objects.
- Reply-to: sourceware-bugzilla at sourceware dot org
// 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.