François Dumont | 9 May 23:02
Picon

[v3] fix libstdc++/53263

Here is a patch for PR 53263.

I have also generalize the idea of performing checks on unsafe iterators 
for better performance to several other debug checks.

2012-05-09  François Dumont <fdumont <at> gcc.gnu.org>

     PR libstdc++/53263
     * include/debug/safe_iterator.h (__gnu_debug::__base): Move...
     * include/debug/functions.h: ... Here. Add debug function
     overloads to perform checks on normal iterators when possible.
     * include/debug/macros.h (__glibcxx_check_heap,
     __glibcxx_check_heap_pred): Use __gnu_debug::__base on iterator range.

Tested under linux x86_64 debug mode.

Ok for trunk and 4.7 branch ?

François

Index: include/debug/functions.h
===================================================================
--- include/debug/functions.h	(revision 187292)
+++ include/debug/functions.h	(working copy)
@@ -31,7 +31,8 @@
 #define _GLIBCXX_DEBUG_FUNCTIONS_H 1

 #include <bits/c++config.h>
(Continue reading)

Jonathan Wakely | 6 May 00:59
Picon

Thoughts on supporting the C++11 thread library on Windows

For GCC 4.7 I enabled most of <thread> (without timed mutexes) on Mac
OS X by making the _GLIBCXX_HAS_GTHREADS macro more fine-grained.  I
think we could quite easily do the same again for the win32 thread
model (defined in gthr-win32.h) so that <thread> and <mutex> are
available (including timed mutexes), but without <condition_variable>
and <future>.

It's harder to support <condition_variable> because Windows didn't
provide condition variables until Vista, and even then they interact
with a CRITICAL_SECTION and gthr-win32.h defines mutexes in terms of a
semaphore not a critical section.  Douglas Schmidt describes an
implementation of condition variables at
http://www.cs.wustl.edu/~schmidt/win32-cv-1.html but that also
requires mutexes to be critical sections - maybe that could be adapted
to use the gthr-win32.h semaphore-based definition of
__gthread_mutex_t, I haven't looked into it in detail.   My suggestion
would be to support <thread> and <mutex> but not <condition_variable>
(or <future> because our implementation uses a
std::condition_variable.)  I have some untested implementations of
__gthread_create, __gthread_join etc. if anyone wants to work on
implementing that suggestion.  I don't have a Windows machine or
enough free time to do that myself in the near future.

As a second idea, supporting the full C++11 thread library could be
done by creating a new thread model to be used instead of win32, which
would only be supported on Vista or later and would use Windows
critical sections for std::mutex and Windows  condition variables for
std::condition_variable.  Critical sections don't support a timed
wait, so that thread model would be similar to the Mac OS X support
and omit timed mutexes.  That could easily be solved by implementing
(Continue reading)

Diego Novillo | 3 May 22:05
Picon
Favicon

GNU Tools Cauldron 2012 - Hotels and registered presentations


An update on the GNU Tools Cauldron (http://gcc.gnu.org/wiki/cauldron2012)

We have published an initial schedule for the workshop.  It is
available at http://gcc.gnu.org/wiki/cauldron2012.

Presenters, please double-check your entries.  If you find
anything missing or wrong, please contact me and I will correct
it.

Thank you.

Benjamin De Kosnik | 3 May 18:29
Picon
Favicon

[v3] doxygen markup for template parameters


In libstdc++/44015, there is a request for doxygen markup on template
parameters, including default arguments. This is a kind of markup that
libstdc++ has mostly not done, or done inconsistently.

So, here's how I think it should be done, at least for io and
containers. 

See generated files here:
http://gcc.gnu.org/onlinedocs/libstdc++/latest-doxygen/index.html

tested x86/linux

-benjamin
2012-05-02  Benjamin Kosnik  <bkoz <at> redhat.com>

	PR libstdc++/44015
	* include/bits/basic_ios.h: Add tparam markup for
	* doxygen.  include/bits/basic_string.h: Same.
	* include/bits/forward_list.h: Same.
	* include/bits/stl_bvector.h: Same.
	* include/bits/stl_deque.h: Same.
	* include/bits/stl_list.h: Same.  include/bits/stl_map.h:
	* Same.  include/bits/stl_multimap.h: Same.
	* include/bits/stl_multiset.h: Same.
	* include/bits/stl_pair.h: Same.
	* include/bits/stl_queue.h: Same.
	* include/bits/stl_set.h: Same.
	* include/bits/stl_stack.h: Same.
(Continue reading)

Samuel David | 3 May 18:16
Picon

Re: Missing compile-time warning for orphaned memory

Hi gcc team,

The following code creates orphaned memory by ignoring the return value of new:

#include<iostream>
using namespace std;

int main ( void ) {
    for (int i=0; i< 10000000; i++)
        new int[10000000];
    int a;
    cin >> a;

    return 0;
}

Should g++ report a compile-time warning for this case?

root <at> quant:/tmp# g++ -Wall -Wextra MemoryLeakCheckCompilerWarning.cpp
-o MemoryLeakCheckCompilerWarning.exe
root <at> quant:/tmp#

Warm regards,
-S

Benjamin De Kosnik | 2 May 18:38
Picon
Favicon

[v3] hashtable fw decl fix


This patchlette needed for versioned builds, just makes
declaration/foward declaration consistent.

-benjamin

tested x86/linux
tested x86/linux versioned namespaces
diff --git a/libstdc++-v3/include/bits/hashtable_policy.h b/libstdc++-v3/include/bits/hashtable_policy.h
index 3b43510..a42d3d3 100644
--- a/libstdc++-v3/include/bits/hashtable_policy.h
+++ b/libstdc++-v3/include/bits/hashtable_policy.h
@@ -33,12 +33,16 @@

 namespace std _GLIBCXX_VISIBILITY(default)
 {
+_GLIBCXX_BEGIN_NAMESPACE_VERSION
+
   template<typename _Key, typename _Value, typename _Alloc,
 	   typename _ExtractKey, typename _Equal,
 	   typename _H1, typename _H2, typename _Hash,
 	   typename _RehashPolicy, typename _Traits>
     class _Hashtable;

+_GLIBCXX_END_NAMESPACE_VERSION
+
 namespace __detail
 {
 _GLIBCXX_BEGIN_NAMESPACE_VERSION
(Continue reading)

Paolo Carlini | 30 Apr 01:37
Picon
Favicon

[v3] Completely fix libstdc++/51795 in mainline

Hi,

contributed by Marc (thanks Again!) and integrated by me. Tested 
x86_64-linux, multilib. Committed to mainline.

Thanks,
Paolo.

///////////////////////////
2012-04-29  Marc Glisse  <marc.glisse <at> inria.fr>
	    Paolo Carlini  <paolo.carlini <at> oracle.com>

	PR libstdc++/51795
	* include/bits/stl_algobase.h (__lg<>(_Size)): Remove.
	(__lg(int), __lg(unsigned), __lg(long), __lg(unsigned long),
	__lg(long long), __lg(unsigned long long)): Define constexpr.
	* include/bits/random.h (_Mod<>): Overcome Schrage's algorithm
	limitations.
	(__mod): Adjust.
	(linear_congruential): Remove FIXME static_assert.
	* include/bits/random.tcc (_Mod<>): Adjust.
	* testsuite/26_numerics/random/linear_congruential_engine/operators/
	51795.cc: New.
Index: include/bits/stl_algobase.h
===================================================================
--- include/bits/stl_algobase.h	(revision 186943)
(Continue reading)

Jonathan Wakely | 30 Apr 01:16
Picon

[v3] constrain std::function constructor to only accept callable types

Currently we only constrain std::function's constructor to reject
integral arguments, this patch changes it to reject non-callable
arguments.  This is the proposed resolution of LWG 2132, I had already
planned to do this anyway before the issue was opened so I don't see
any need to wait for a DR.

        * include/std/functional (function::function(F)): LWG 2132: Disable
        constructor if argument isn't callable.
        * testsuite/20_util/function/cons/callable.cc: New.

Tested x86_64-linux, committed to trunk.
commit 0e069c4221d6ed4fda7d10938470c472170dcad7
Author: Jonathan Wakely <jwakely.gcc <at> gmail.com>
Date:   Tue Feb 14 22:22:48 2012 +0000

    	* include/std/functional (function::function(F)): LWG 2132: Disable
    	constructor if argument isn't callable.
    	* testsuite/20_util/function/cons/callable.cc: New.

diff --git a/libstdc++-v3/include/std/functional b/libstdc++-v3/include/std/functional
index 980c6ab..0edb4f1 100644
--- a/libstdc++-v3/include/std/functional
+++ b/libstdc++-v3/include/std/functional
@@ -1856,7 +1856,7 @@ _GLIBCXX_HAS_NESTED_TYPE(result_type)
       {
 	typedef _Function_base::_Base_manager<_Functor*> _Base;

-    public:
(Continue reading)

François Dumont | 29 Apr 12:21
Picon

PR 53115

Hi

     Here is the patch for this PR. We were using buckets before 
updating them after having inserted equivalents elements one after the 
another.

2012-04-29  François Dumont <fdumont <at> gcc.gnu.org>

     PR libstdc++/53115
     * include/bits/hashtable.h
     (_Hashtable<>::_M_rehash_aux(size_type, false_type)): Fix buckets
     after insertion of several equivalent elements.
     * testsuite/23_containers/unordered_multiset/insert/53115.cc: New.

     Tested undex linux x86_64 in the 4.7 branch, normal and debug mode.

     Ok to commit ?

François
Index: include/bits/hashtable.h
===================================================================
--- include/bits/hashtable.h	(revision 186930)
+++ include/bits/hashtable.h	(working copy)
@@ -1,6 +1,7 @@
 // hashtable.h header -*- C++ -*-

-// Copyright (C) 2007, 2008, 2009, 2010, 2011 Free Software Foundation, Inc.
+// Copyright (C) 2007, 2008, 2009, 2010, 2011, 2012
(Continue reading)

François Dumont | 28 Apr 10:01
Picon

Remove algo code duplication

Hi

     Here is an other attempt to remove duplication of code in 
implementation of Standard algos. There are several enhancements on the 
last proposal:

1. No usage of C++11 lambdas anymore, code works fine in C++98 and code 
has been really deleted this time. About 700 lines removed in stl_algo.h 
for instance.

2. Compatible with existing code, code submitted by Christopher last 
time will still compile. To do so I used 
std::iterator_traits<>::reference type so that if the iterator is not 
const then the operator do not have to take const reference or to be 
const qualified neither. For the same reason I have also avoided some 
const qualifiers on the introduced functors.

3. It is less complex than in libstdcxx_so_7 branch: Introduced functors 
always have one operator() so that ambiguity between different overloads 
is impossible. To do so I used 2 techniques:
     - For equal_range and lexicographical_compare algos, the ones that 
really need 2 overloads, I simply pass 2 functors, one to do lhs < rhs 
and one for rhs < lhs; when the functor comes from the user code it is 
the same that is passed twice.
     - In other more complex situation where an algorithm calls other 
internal algos resulting in the functor being called with potentially 
many slightly different parameter types I use a rebind technique. When 
there is a call to an internal algo that need a specific functor 
signature I rebind the input functor to match it. In _RebindHelper I 
detect when the functor is my newly introduced __gnu_cxx::__ops::less 
(Continue reading)

Picon

Default buffer size of class basic_filebuf

Hello!

I want to figure out the default buffer-size of the class basic_filebuf.
I know the member function pubsetbuf() and it seems to have a great
impact on the performance during file copy.

Question: Where I can find the default buffer size for basic_filebuf?

The standard for C++ doesn't define a member function pubgetbuf() or
something like this, also the member function is_avail() doesn't help
either. I can't find any constant. I know BUFSIZ from <cstdio> and it
defaults on my machine to 8192 Bytes, which performs well for me with
fread()/fwrite() and read()/write().

I doing some testing on simple file copying:
http://stackoverflow.com/questions/10195343/copy-a-file-in-an-sane-safe-and-efficient-way

Thanks
Peter Weber

Gmane