Bug 58729 - tr2::dynamic_bitset::resize fails
Summary: tr2::dynamic_bitset::resize fails
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: libstdc++ (show other bugs)
Version: 4.8.1
: P3 minor
Target Milestone: 4.9.0
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-10-14 21:01 UTC by Kyle Bentley
Modified: 2013-10-26 16:13 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2013-10-14 00:00:00


Attachments
output from compilation (114.84 KB, text/plain)
2013-10-14 21:01 UTC, Kyle Bentley
Details
output from the compile(as seen from terminal) (2.87 KB, text/plain)
2013-10-14 21:04 UTC, Kyle Bentley
Details
Source code (482 bytes, text/plain)
2013-10-14 21:04 UTC, Kyle Bentley
Details
Code output (102 bytes, text/plain)
2013-10-14 21:09 UTC, Kyle Bentley
Details
Patch dynamic_bitset... (4.90 KB, patch)
2013-10-16 11:31 UTC, Ed Smith-Rowland
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Kyle Bentley 2013-10-14 21:01:48 UTC
Created attachment 31004 [details]
output from compilation

using g++ (Debian 4.8.1-10) 4.8.1
Debian testing x64

I've been investigating the dynamic_bitset part of the tr2 specification.  I've used boost's dynamic bitset, so I was basing the functionality from that.  Either I'm using the resize function wrongly, or it's failing to set the bits as indicated.

When using the resize(number of bits, value), the resize seems to work fine, but the value is ignored.  I started to dig around; the resize function is defined as this in the header <tr2/dynamic_bitset>

      void
      resize(size_type __nbits, bool __value = false)
      {
	this->_M_resize(__nbits, __value);
	this->_M_Nb = __nbits;
	this->_M_do_sanitize();
      }

Is the value being defaulted to false, regardless of the input?  The actual main() is at the end of the main.ii file.  Another oddity is that this will not compile from the command line, but will from inside netbeans where I code, even with Wall and Wextra specified.

If more info is needed, I'll oblige.
Comment 1 Kyle Bentley 2013-10-14 21:04:12 UTC
Created attachment 31005 [details]
output from the compile(as seen from terminal)
Comment 2 Kyle Bentley 2013-10-14 21:04:59 UTC
Created attachment 31006 [details]
Source code
Comment 3 Kyle Bentley 2013-10-14 21:09:20 UTC
Created attachment 31007 [details]
Code output
Comment 4 Paolo Carlini 2013-10-14 21:14:38 UTC
First blush the problem is in _M_resize: it ignores the __value passed as argument. That can't be right. Ed can you have a look?
Comment 5 Ed Smith-Rowland 2013-10-15 00:48:50 UTC
This is wrong.  Testing a patch...
Comment 6 Ed Smith-Rowland 2013-10-16 11:31:18 UTC
Created attachment 31017 [details]
Patch dynamic_bitset...

Here is the patch.  I did a little extra work to move large functions offline and to fix other things that were broken.  This class was dumped in before it was ready really.

tested on x86_64-linux.

I tried retesting this morning but it looks like bootstrap is broken.

See what you think.
Comment 7 Jonathan Wakely 2013-10-16 11:49:08 UTC
Comment on attachment 31017 [details]
Patch dynamic_bitset...

The new dynamic_bitset.tcc file should have a different doxygen block from the main header:

+/** @file tr2/dynamic_bitset
+ *  This is a TR2 C++ Library header.
+ */

I suggest:

/** @file tr2/dynamic_bitset.tcc
 *  This is an internal header file, included by other library headers.
 *  Do not attempt to use it directly. @headername{tr2/dynamic_bitset}
Comment 8 Paolo Carlini 2013-10-16 11:57:22 UTC
By the way, I just fixed the bootstrap. When you are ready, please send the patch to the mailing list, thanks!
Comment 9 Jonathan Wakely 2013-10-16 12:33:15 UTC
Also, your doxygen markup is not valid, this does not start a group:

+  //@{
+
+  /**
+   *  @brief Global I/O operators for bitsets.
+   *

That just adds the @brief to the next function, I think you want:

  /**
   *  @defgroup Global I/O operators for bitsets.
   *  @{
   */
Comment 10 Ed Smith-Rowland 2013-10-16 12:53:31 UTC
The pt.c fix worked but...

Still getting:
In file included from ../../gcc/gcc/lto/lto.c:3301:0:
./gt-lto-lto.h:153:6: error: ‘type_hash_cache’ was not declared in this scope
./gt-lto-lto.h:155:13: error: ‘type_hash_cache’ was not declared in this scope
./gt-lto-lto.h:161:6: error: ‘gimple_types’ was not declared in this scope
./gt-lto-lto.h:163:13: error: ‘gimple_types’ was not declared in this scope
./gt-lto-lto.h:173:6: error: ‘type_hash_cache’ was not declared in this scope
./gt-lto-lto.h:175:13: error: ‘type_hash_cache’ was not declared in this scope
./gt-lto-lto.h:180:6: error: ‘gimple_types’ was not declared in this scope
./gt-lto-lto.h:182:13: error: ‘gimple_types’ was not declared in this scope

I have to run.  I'll try again tonight.
Comment 11 Paolo Carlini 2013-10-16 13:08:48 UTC
I don't see that. Boot & test just completed successfully for me.
Comment 12 Paolo Carlini 2013-10-16 13:24:34 UTC
In my x86_64 -m64 build, gt-lto-lto.h has only 149 lines. Looks like your tree is in an inconsistent state.
Comment 13 Ed Smith-Rowland 2013-10-19 01:31:22 UTC
Author: emsr
Date: Sat Oct 19 01:31:19 2013
New Revision: 203841

URL: http://gcc.gnu.org/viewcvs?rev=203841&root=gcc&view=rev
Log:
2013-10-18  Edward Smith-Rowland  <3dw4rd@verizon.net>

	PR libstdc++/58729
	* include/tr2/dynamic_bitset (_M_resize, resize): Use input value
	to set bits; (_M_do_left_shift, _M_do_right_shift, _M_do_to_ulong,
	_M_do_to_ullong, _M_do_find_first, _M_do_find_next, _M_copy_from_ptr,
	operator>>): Move long methods outline to...
	* include/tr2/dynamic_bitset.tcc: New.
	* include/Makefile.am: Add dynamic_bitset.tcc.
	* include/Makefile.in: Add dynamic_bitset.tcc.
	* testsuite/tr2/dynamic_bitset/pr58729.cc: New.


Added:
    trunk/libstdc++-v3/include/tr2/dynamic_bitset.tcc
    trunk/libstdc++-v3/testsuite/tr2/dynamic_bitset/
    trunk/libstdc++-v3/testsuite/tr2/dynamic_bitset/pr58729.cc
Modified:
    trunk/libstdc++-v3/ChangeLog
    trunk/libstdc++-v3/include/Makefile.am
    trunk/libstdc++-v3/include/Makefile.in
    trunk/libstdc++-v3/include/tr2/dynamic_bitset
Comment 14 Ed Smith-Rowland 2013-10-19 21:35:47 UTC
See http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58804 for work that will get this to work for -m32 also.

I was using builtins for long rather than long long so the last patch failed with -m32.  Sigh...
Comment 15 Ed Smith-Rowland 2013-10-21 13:52:42 UTC
Author: emsr
Date: Mon Oct 21 13:52:39 2013
New Revision: 203893

URL: http://gcc.gnu.org/viewcvs?rev=203893&root=gcc&view=rev
Log:
2013-10-20  Edward Smith-Rowland  <3dw4rd@verizon.net>

	PR libstdc++/58804
	PR libstdc++/58729
	* include/tr2/dynamic_bitset
	(__dynamic_bitset_base<_WordT, _Alloc>::_M_are_all_aux,
	__dynamic_bitset_base<_WordT, _Alloc>::_M_do_count):
	Use __builtin_popcountll() instead of __builtin_popcountl().
	* include/tr2/dynamic_bitset.tcc
	(__dynamic_bitset_base<_WordT, _Alloc>::_M_do_find_first,
	__dynamic_bitset_base<_WordT, _Alloc>::_M_do_find_next):
	Use __builtin_ctzll() instead of __builtin_ctzl().


Modified:
    trunk/libstdc++-v3/ChangeLog
    trunk/libstdc++-v3/include/tr2/dynamic_bitset
    trunk/libstdc++-v3/include/tr2/dynamic_bitset.tcc
Comment 16 Paolo Carlini 2013-10-21 13:57:35 UTC
Fixed.