From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2205) id 496913839C6C; Thu, 12 May 2022 12:52:45 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 496913839C6C Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Tom de Vries To: gdb-cvs@sourceware.org Subject: [binutils-gdb] [gdb/testsuite] Fix gdb.cp/break-f-std-string.cc with older gcc X-Act-Checkin: binutils-gdb X-Git-Author: Tom de Vries X-Git-Refname: refs/heads/master X-Git-Oldrev: 678dc756a5741d278be2e14630bc10d2fb31a22a X-Git-Newrev: c8a9e88bf6ff32d90d082d07d3c5d12b938f8335 Message-Id: <20220512125245.496913839C6C@sourceware.org> Date: Thu, 12 May 2022 12:52:45 +0000 (GMT) X-BeenThere: gdb-cvs@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 12 May 2022 12:52:45 -0000 https://sourceware.org/git/gitweb.cgi?p=3Dbinutils-gdb.git;h=3Dc8a9e88bf6ff= 32d90d082d07d3c5d12b938f8335 commit c8a9e88bf6ff32d90d082d07d3c5d12b938f8335 Author: Tom de Vries Date: Thu May 12 14:52:41 2022 +0200 [gdb/testsuite] Fix gdb.cp/break-f-std-string.cc with older gcc =20 When running test-case gdb.cp/break-f-std-string.exp on openSUSE Leap 1= 5.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=3D1: \ whatis /r std::string ... The same for gcc 8.2.1, but it passes with gcc 9.3.1. =20 At source level (as we can observe in the .ii file with -save-temps) we= have indeed: ... namespace std { namespace __cxx11 { typedef basic_string string; } } ... while with gcc 9.3.1, we have instead: ... namespace std { namespace __cxx11 { ... } typedef basic_string string; } ... due to gcc commit 33b43b0d8cd ("Define std::string and related typedefs outside __cxx11 namespace"). =20 Fix this by adding the missing typedef for gcc version 5 (the first ver= sion to have the dual abi) to 8 (the last version missing aforementioned gcc co= mmit). =20 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 Diff: --- gdb/testsuite/gdb.cp/break-f-std-string.cc | 13 +++++++++++++ 1 file changed, 13 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..0c361234d82 100644 --- a/gdb/testsuite/gdb.cp/break-f-std-string.cc +++ b/gdb/testsuite/gdb.cp/break-f-std-string.cc @@ -17,6 +17,19 @@ =20 #include =20 +#if _GLIBCXX_USE_CXX11_ABI =3D=3D 1 +#if defined (__GNUC__) && (__GNUC__ >=3D 5) && (__GNUC__ <=3D 8) + +/* Work around missing std::string typedef before gcc commit + "Define std::string and related typedefs outside __cxx11 namespace". */ + +namespace std { +typedef __cxx11::string string; +} + +#endif +#endif + void f (std::string s) {