[PATCH] libstdc++: Fix libstdc++/67440: pretty-printing of a const set<foo> fails

Doug Evans dje@google.com
Wed Nov 25 18:57:00 GMT 2015


On Wed, Nov 25, 2015 at 9:29 AM, Alan Lawrence <alan.lawrence@arm.com> wrote:
> On 16/11/15 21:04, Doug Evans wrote:
>>
>> Hi.
>>
>> Apologies for the delay.
>> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67440
>>
>> Tested with current trunk.
>>
>> 2015-11-16  Doug Evans  <dje@google.com>
>>
>>      PR libstdc++/67440
>>      * python/libstdcxx/v6/printers.py (find_type): Handle "const" in
>>      type name.
>>      * testsuite/libstdc++-prettyprinters/debug.cc: Add test for
>>      const set<int>.
>>      * testsuite/libstdc++-prettyprinters/simple.cc: Ditto.
>>      * testsuite/libstdc++-prettyprinters/simple11.cc: Ditto.
>
>
> On gcc-5-branch, the debug.cc and simple.cc tests don't seem to compile, on
> either x86_64-none-linux-gnu or aarch64-none-linux-gnu. I get errors like:
>
> /work/alalaw01/src/gcc/libstdc++-v3/testsuite/libstdc++-prettyprinters/simple.cc:
> In function 'int main()':
> /work/alalaw01/src/gcc/libstdc++-v3/testsuite/libstdc++-prettyprinters/simple.cc:77:43:
> error: in C++98 'const_intset' must be initialized by constructor, not by
> '{...}'
>    const std::set<int> const_intset = {2, 3};
>                                            ^
> In file included from
> /work/alalaw01/build_dje/x86_64-unknown-linux-gnu/libstdc++-v3/include/map:60:0,
>                  from
> /work/alalaw01/src/gcc/libstdc++-v3/testsuite/libstdc++-prettyprinters/simple.cc:31:
> /work/alalaw01/build_dje/x86_64-unknown-linux-gnu/libstdc++-v3/include/bits/stl_tree.h:
> In instantiation of 'void std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare,
> _Alloc>::_M_insert_unique(_II, _II) [with _InputIterator = int; _Key = int;
> _Val = int; _KeyOfValue = std::_Identity<int>; _Compare = std::less<int>;
> _Alloc = std::allocator<int>]':
> /work/alalaw01/build_dje/x86_64-unknown-linux-gnu/libstdc++-v3/include/bits/stl_set.h:171:4:
> required from 'std::set<_Key, _Compare, _Alloc>::set(_InputIterator,
> _InputIterator) [with _InputIterator = int; _Key = int; _Compare =
> std::less<int>; _Alloc = std::allocator<int>]'
> /work/alalaw01/src/gcc/libstdc++-v3/testsuite/libstdc++-prettyprinters/simple.cc:77:43:
> required from here
> /work/alalaw01/build_dje/x86_64-unknown-linux-gnu/libstdc++-v3/include/bits/stl_tree.h:2224:29:
> error: invalid type argument of unary '*' (have 'int')
>     _M_insert_unique_(end(), *__first, __an);
>                              ^
> compiler exited with status 1
> UNRESOLVED: libstdc++-prettyprinters/simple.cc compilation failed to produce
> executable
> Spawning: gdb -nw -nx -quiet -batch -ex "python print(gdb.type_printers)"
> spawn gdb -nw -nx -quiet -batch -ex python print(gdb.type_printers)
> []
> spawn gdb -nx -nw -quiet -batch -x simple.gdb
> simple.gdb:2: Error in sourced command file:
> ./simple.exe: No such file or directory.
> skipping: simple.gdb:2: Error in sourced command file:
> skipping: ./simple.exe: No such file or directory.
> UNSUPPORTED: libstdc++-prettyprinters/simple.cc
>
> I also see signs of the same on powerpc64le
> (https://gcc.gnu.org/ml/gcc-testresults/2015-11/msg02699.html), the test
> looks to be passing on trunk on all three platforms.
>
> Thanks, Alan

Bleah, mea culpa.

While we might be able to revise the testcase and keep the fix,
I think a good first step is to just revert.
-------------- next part --------------
2015-11-25  Doug Evans  <dje@google.com>

	Revert:
	PR libstdc++/67440
	* python/libstdcxx/v6/printers.py (find_type): Handle "const" in
	type name.
	* testsuite/libstdc++-prettyprinters/debug.cc: Add test for
	const set<int>.
	* testsuite/libstdc++-prettyprinters/simple.cc: Ditto.
	* testsuite/libstdc++-prettyprinters/simple11.cc: Ditto.

Index: python/libstdcxx/v6/printers.py
===================================================================
--- python/libstdcxx/v6/printers.py	(revision 230895)
+++ python/libstdcxx/v6/printers.py	(working copy)
@@ -85,9 +85,7 @@
 def find_type(orig, name):
     typ = orig.strip_typedefs()
     while True:
-        # Use typ.name here instead of str(typ) to discard any const,etc.
-        # qualifiers.  PR 67440.
-        search = typ.name + '::' + name
+        search = str(typ) + '::' + name
         try:
             return gdb.lookup_type(search)
         except RuntimeError:
Index: testsuite/libstdc++-prettyprinters/debug.cc
===================================================================
--- testsuite/libstdc++-prettyprinters/debug.cc	(revision 230895)
+++ testsuite/libstdc++-prettyprinters/debug.cc	(working copy)
@@ -70,10 +70,6 @@
   std::map<std::string, int>::iterator mpiter = mp.begin();
 // { dg-final { note-test mpiter {{first = "zardoz", second = 23}} } }
 
-  // PR 67440
-  const std::set<int> const_intset = {2, 3};
-// { dg-final { note-test const_intset {std::__debug::set with 2 elements = {[0] = 2, [1] = 3}} } }
-
   std::set<std::string> sp;
   sp.insert("clownfish");
   sp.insert("barrel");
Index: testsuite/libstdc++-prettyprinters/simple.cc
===================================================================
--- testsuite/libstdc++-prettyprinters/simple.cc	(revision 230895)
+++ testsuite/libstdc++-prettyprinters/simple.cc	(working copy)
@@ -73,10 +73,6 @@
   std::map<std::string, int>::iterator mpiter = mp.begin();
 // { dg-final { note-test mpiter {{first = "zardoz", second = 23}} } }
 
-  // PR 67440
-  const std::set<int> const_intset = {2, 3};
-// { dg-final { note-test const_intset {std::set with 2 elements = {[0] = 2, [1] = 3}} } }
-
   std::set<std::string> sp;
   sp.insert("clownfish");
   sp.insert("barrel");
Index: testsuite/libstdc++-prettyprinters/simple11.cc
===================================================================
--- testsuite/libstdc++-prettyprinters/simple11.cc	(revision 230895)
+++ testsuite/libstdc++-prettyprinters/simple11.cc	(working copy)
@@ -73,10 +73,6 @@
   std::map<std::string, int>::iterator mpiter = mp.begin();
 // { dg-final { note-test mpiter {{first = "zardoz", second = 23}} } }
 
-  // PR 67440
-  const std::set<int> const_intset = {2, 3};
-// { dg-final { note-test const_intset {std::set with 2 elements = {[0] = 2, [1] = 3}} } }
-
   std::set<std::string> sp;
   sp.insert("clownfish");
   sp.insert("barrel");


More information about the Gcc-patches mailing list