* [PATCH][gdb/testsuite] Fix gdb.cp/break-f-std-string.cc with older gcc
@ 2022-05-12 11:45 Tom de Vries
2022-05-12 12:47 ` Pedro Alves
0 siblings, 1 reply; 3+ messages in thread
From: Tom de Vries @ 2022-05-12 11:45 UTC (permalink / raw)
To: gdb-patches; +Cc: Pedro Alves
Hi,
When running test-case gdb.cp/break-f-std-string.exp on openSUSE Leap 15.3
with system gcc 7.5.0, I run into:
...
(gdb) whatis /r std::string^M
No symbol "string" in namespace "std".^M
(gdb) FAIL: gdb.cp/break-f-std-string.exp: _GLIBCXX_USE_CXX11_ABI=1: \
whatis /r std::string
...
The same for gcc 8.2.1, but it passes with gcc 9.3.1.
At source level (as we can observe in the .ii file with -save-temps) we have
indeed:
...
namespace std {
namespace __cxx11 {
typedef basic_string<char> string;
}
}
...
while with gcc 9.3.1, we have instead:
...
namespace std {
namespace __cxx11 {
...
}
typedef basic_string<char> string;
}
...
due to gcc commit 33b43b0d8cd ("Define std::string and related typedefs
outside __cxx11 namespace").
Fix this by adding the missing typedef for gcc version 5 (the first version to
have the dual abi) to 8 (the last version missing aforementioned gcc commit).
Tested on x86_64-linux, with:
- system gcc 7.5.0
- gcc 4.8.5, 8.2.1, 9.3.1, 10.3.0, 11.2.1
- clang 8.0.1, 12.0.1
Any comments?
Thanks,
- Tom
[gdb/testsuite] Fix gdb.cp/break-f-std-string.cc with older gcc
---
gdb/testsuite/gdb.cp/break-f-std-string.cc | 14 ++++++++++++++
1 file changed, 14 insertions(+)
diff --git a/gdb/testsuite/gdb.cp/break-f-std-string.cc b/gdb/testsuite/gdb.cp/break-f-std-string.cc
index 454ab4c42ea..cbbfeebac60 100644
--- a/gdb/testsuite/gdb.cp/break-f-std-string.cc
+++ b/gdb/testsuite/gdb.cp/break-f-std-string.cc
@@ -17,6 +17,20 @@
#include <string>
+#if _GLIBCXX_USE_CXX11_ABI == 1
+#if defined (__GNUC__) && (__GNUC__ >= 5) && (__GNUC__ <= 8)
+
+// Work around missing std::string typedef before gcc commit
+// "Define std::string and related typedefs outside __cxx11 namespace".
+
+namespace std {
+using namespace __cxx11;
+typedef __cxx11::string string;
+}
+
+#endif
+#endif
+
void
f (std::string s)
{
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH][gdb/testsuite] Fix gdb.cp/break-f-std-string.cc with older gcc
2022-05-12 11:45 [PATCH][gdb/testsuite] Fix gdb.cp/break-f-std-string.cc with older gcc Tom de Vries
@ 2022-05-12 12:47 ` Pedro Alves
2022-05-12 12:57 ` Tom de Vries
0 siblings, 1 reply; 3+ messages in thread
From: Pedro Alves @ 2022-05-12 12:47 UTC (permalink / raw)
To: Tom de Vries, gdb-patches
On 2022-05-12 12:45, Tom de Vries wrote:
> [gdb/testsuite] Fix gdb.cp/break-f-std-string.cc with older gcc
>
> ---
> gdb/testsuite/gdb.cp/break-f-std-string.cc | 14 ++++++++++++++
> 1 file changed, 14 insertions(+)
>
> diff --git a/gdb/testsuite/gdb.cp/break-f-std-string.cc b/gdb/testsuite/gdb.cp/break-f-std-string.cc
> index 454ab4c42ea..cbbfeebac60 100644
> --- a/gdb/testsuite/gdb.cp/break-f-std-string.cc
> +++ b/gdb/testsuite/gdb.cp/break-f-std-string.cc
> @@ -17,6 +17,20 @@
>
> #include <string>
>
> +#if _GLIBCXX_USE_CXX11_ABI == 1
> +#if defined (__GNUC__) && (__GNUC__ >= 5) && (__GNUC__ <= 8)
> +
> +// Work around missing std::string typedef before gcc commit
> +// "Define std::string and related typedefs outside __cxx11 namespace".
Since we try to follow the GDB conventions in the tests too, this should
use /**/ comments.
> +
> +namespace std {
> +using namespace __cxx11;
Why is this "using namespace __cxx11;" needed? I guess something about the
"related typedefs" mentioned in the comment? The test passes for me without
that, on GCC 6.5 (the only affected compiler I have handy atm), like:
namespace std {
typedef __cxx11::string string;
}
Otherwise LGTM.
Pedro Alves
> +typedef __cxx11::string string;
> +}
> +
> +#endif
> +#endif
> +
> void
> f (std::string s)
> {
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH][gdb/testsuite] Fix gdb.cp/break-f-std-string.cc with older gcc
2022-05-12 12:47 ` Pedro Alves
@ 2022-05-12 12:57 ` Tom de Vries
0 siblings, 0 replies; 3+ messages in thread
From: Tom de Vries @ 2022-05-12 12:57 UTC (permalink / raw)
To: Pedro Alves, gdb-patches
On 5/12/22 14:47, Pedro Alves wrote:
> On 2022-05-12 12:45, Tom de Vries wrote:
>
>> [gdb/testsuite] Fix gdb.cp/break-f-std-string.cc with older gcc
>>
>> ---
>> gdb/testsuite/gdb.cp/break-f-std-string.cc | 14 ++++++++++++++
>> 1 file changed, 14 insertions(+)
>>
>> diff --git a/gdb/testsuite/gdb.cp/break-f-std-string.cc b/gdb/testsuite/gdb.cp/break-f-std-string.cc
>> index 454ab4c42ea..cbbfeebac60 100644
>> --- a/gdb/testsuite/gdb.cp/break-f-std-string.cc
>> +++ b/gdb/testsuite/gdb.cp/break-f-std-string.cc
>> @@ -17,6 +17,20 @@
>>
>> #include <string>
>>
>> +#if _GLIBCXX_USE_CXX11_ABI == 1
>> +#if defined (__GNUC__) && (__GNUC__ >= 5) && (__GNUC__ <= 8)
>> +
>> +// Work around missing std::string typedef before gcc commit
>> +// "Define std::string and related typedefs outside __cxx11 namespace".
>
> Since we try to follow the GDB conventions in the tests too, this should
> use /**/ comments.
>
Ack, fixed.
>> +
>> +namespace std {
>> +using namespace __cxx11;
>
> Why is this "using namespace __cxx11;" needed? I guess something about the
> "related typedefs" mentioned in the comment? The test passes for me without
> that, on GCC 6.5 (the only affected compiler I have handy atm), like:
>
> namespace std {
> typedef __cxx11::string string;
> }
>
Works for me as well, so removed.
> Otherwise LGTM.
>
Thanks for the review, committed.
Thanks,
- Tom
> Pedro Alves
>
>> +typedef __cxx11::string string;
>> +}
>> +
>> +#endif
>> +#endif
>> +
>> void
>> f (std::string s)
>> {
>>
>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2022-05-12 12:57 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-12 11:45 [PATCH][gdb/testsuite] Fix gdb.cp/break-f-std-string.cc with older gcc Tom de Vries
2022-05-12 12:47 ` Pedro Alves
2022-05-12 12:57 ` Tom de Vries
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).