public inbox for gdb-prs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/11993] New: Strange behaviour - invalid information about objects.
@ 2010-09-08 18:00 dmitigr at gmail dot com
2010-09-08 18:02 ` [Bug c++/11993] " dmitigr at gmail dot com
2010-09-09 7:46 ` dmitigr at gmail dot com
0 siblings, 2 replies; 4+ messages in thread
From: dmitigr at gmail dot com @ 2010-09-08 18:00 UTC (permalink / raw)
To: gdb-prs
// 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.
^ permalink raw reply [flat|nested] 4+ messages in thread
[parent not found: <bug-11993-4717@http.sourceware.org/bugzilla/>]
* [Bug c++/11993] Strange behaviour - invalid information about objects.
[not found] <bug-11993-4717@http.sourceware.org/bugzilla/>
@ 2020-04-05 11:12 ` ssbssa at sourceware dot org
0 siblings, 0 replies; 4+ messages in thread
From: ssbssa at sourceware dot org @ 2020-04-05 11:12 UTC (permalink / raw)
To: gdb-prs
https://sourceware.org/bugzilla/show_bug.cgi?id=11993
Hannes Domani <ssbssa at sourceware dot org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |ssbssa at sourceware dot org
--- Comment #2 from Hannes Domani <ssbssa at sourceware dot org> ---
I can not reproduce this problem, not even with the oldest gdb version I still
have (7.8).
(gdb) b 37
Breakpoint 1 at 0x401665: file gdb-11993.cpp, line 37.
(gdb) b 25
Breakpoint 2 at 0x419965: file gdb-11993.cpp, line 25.
(gdb) r
Starting program: C:\src\tests\gdb-11993.exe
[New Thread 3804.0x1db4]
Breakpoint 1, A<int>::f[abi:cxx11](int const&) (value=@0x22fe1c: 1) at
gdb-11993.cpp:38
38 << " s.size() = " << s.size() << std::endl;
(gdb) p s
$1 = {static npos = 18446744073709551615, _M_dataplus = {<std::allocator<char>>
= {<__gnu_cxx::new_allocator<char>> = {<No data fields>}, <No data fields>},
_M_p = 0x22fe00 "Alex"}, _M_string_length = 4, {_M_local_buf =
"Alex\000\000\000\000¦\037\064\000\000\000\000", _M_allocated_capacity =
2019912769}}
(gdb) p s.size()
$2 = 4
(gdb) c
Continuing.
A<int>::f(): s = "Alex" s.size() = 4
Breakpoint 2, A<double>::f[abi:cxx11](double const&) (value=@0x22fe48:
2.2999999999999998) at gdb-11993.cpp:26
26 << " s.size() = " << s.size() << std::endl;
(gdb) p s
$3 = {static npos = 18446744073709551615, _M_dataplus = {<std::allocator<char>>
= {<__gnu_cxx::new_allocator<char>> = {<No data fields>}, <No data fields>},
_M_p = 0x22fe30 "Dima"}, _M_string_length = 4, {_M_local_buf =
"Dima\000\000\000\000\033\000\000\000\000\000\000", _M_allocated_capacity =
1634560324}}
(gdb) p s.size()
$4 = 4
--
You are receiving this mail because:
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2020-04-05 11:12 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-09-08 18:00 [Bug c++/11993] New: Strange behaviour - invalid information about objects dmitigr at gmail dot com
2010-09-08 18:02 ` [Bug c++/11993] " dmitigr at gmail dot com
2010-09-09 7:46 ` dmitigr at gmail dot com
[not found] <bug-11993-4717@http.sourceware.org/bugzilla/>
2020-04-05 11:12 ` ssbssa at sourceware dot org
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).