public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libstdc++/52442] New: temporary_buffer does not swap
@ 2012-02-29 21:20 giecrilj at stegny dot 2a.pl
  2012-02-29 22:10 ` [Bug libstdc++/52442] " redi at gcc dot gnu.org
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: giecrilj at stegny dot 2a.pl @ 2012-02-29 21:20 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52442

             Bug #: 52442
           Summary: temporary_buffer does not swap
    Classification: Unclassified
           Product: gcc
           Version: 4.6.2
            Status: UNCONFIRMED
          Severity: enhancement
          Priority: P3
         Component: libstdc++
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: giecrilj@stegny.2a.pl


Created attachment 26792
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=26792
the preprocessed file (*.i*) that triggers the bug

There is currently no way to use a temporary_buffer to implement a
buffer-growing loop as recommended e.g. by gethostname API.  The reason is that
a temporary_buffer does not swap.

  the exact version of GCC: 4.6.2  

  the system type: (SUSE Linux)

  the options given when GCC was configured/built;
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib64/gcc/x86_64-suse-linux/4.6/lto-wrapper
Target: x86_64-suse-linux
Configured with: ../configure --prefix=/usr --infodir=/usr/share/info
--mandir=/usr/share/man --libdir=/usr/lib64 --libexecdir=/usr/lib64
--enable-languages=c,c++,objc,fortran,obj-c++,java,ada
--enable-checking=release --with-gxx-include-dir=/usr/include/c++/4.6
--enable-ssp --disable-libssp --disable-plugin
--with-bugurl=http://bugs.opensuse.org/ --with-pkgversion='SUSE Linux'
--disable-libgcj --disable-libmudflap --with-slibdir=/lib64 --with-system-zlib
--enable-__cxa_atexit --enable-libstdcxx-allocator=new --disable-libstdcxx-pch
--enable-version-specific-runtime-libs --program-suffix=-4.6
--enable-linux-futex --without-system-libunwind --with-arch-32=i586
--with-tune=generic --build=x86_64-suse-linux
Thread model: posix

  the complete command line that triggers the bug: { gcc -c tmpswap.cpp; }

  the compiler output (error messages, warnings, etc.):
In file included from tmpswap.cpp:1:0:
/usr/include/c++/4.6/bits/stl_tempbuf.h: In copy constructor
‘__gnu_cxx::temporary_buffer<char*>::temporary_buffer(const
__gnu_cxx::temporary_buffer<char*>&)’:
/usr/include/c++/4.6/ext/memory:184:12:   instantiated from ‘void
std::swap(_Tp&, _Tp&) [with _Tp = __gnu_cxx::temporary_buffer<char*>]’
tmpswap.cpp:7:22:   instantiated from here
/usr/include/c++/4.6/bits/stl_tempbuf.h:174:7: error:
‘std::_Temporary_buffer<_ForwardIterator, _Tp>::_Temporary_buffer(const
std::_Temporary_buffer<_ForwardIterator, _Tp>&) [with _ForwardIterator = char*,
_Tp = char, std::_Temporary_buffer<_ForwardIterator, _Tp> =
std::_Temporary_buffer<char*, char>]’ is private
/usr/include/c++/4.6/ext/memory:184:12: error: within this context
In file included from /usr/include/c++/4.6/bits/stl_pair.h:60:0,
                 from /usr/include/c++/4.6/bits/stl_algobase.h:65,
                 from /usr/include/c++/4.6/memory:64,
                 from /usr/include/c++/4.6/ext/memory:62,
                 from tmpswap.cpp:1:
/usr/include/c++/4.6/bits/move.h: In function ‘void std::swap(_Tp&, _Tp&) [with
_Tp = __gnu_cxx::temporary_buffer<char*>]’:
tmpswap.cpp:7:22:   instantiated from here
/usr/include/c++/4.6/bits/move.h:127:19: note: synthesized method
‘__gnu_cxx::temporary_buffer<char*>::temporary_buffer(const
__gnu_cxx::temporary_buffer<char*>&)’ first required here 
In file included from tmpswap.cpp:1:0:
/usr/include/c++/4.6/bits/stl_tempbuf.h: In member function
‘__gnu_cxx::temporary_buffer<char*>&
__gnu_cxx::temporary_buffer<char*>::operator=(const
__gnu_cxx::temporary_buffer<char*>&)’:
/usr/include/c++/4.6/bits/stl_tempbuf.h:177:7: error: ‘void
std::_Temporary_buffer<_ForwardIterator, _Tp>::operator=(const
std::_Temporary_buffer<_ForwardIterator, _Tp>&) [with _ForwardIterator = char*,
_Tp = char, std::_Temporary_buffer<_ForwardIterator, _Tp> =
std::_Temporary_buffer<char*, char>]’ is private
/usr/include/c++/4.6/ext/memory:184:12: error: within this context
In file included from /usr/include/c++/4.6/bits/stl_pair.h:60:0,
                 from /usr/include/c++/4.6/bits/stl_algobase.h:65,
                 from /usr/include/c++/4.6/memory:64,
                 from /usr/include/c++/4.6/ext/memory:62,
                 from tmpswap.cpp:1:
/usr/include/c++/4.6/bits/move.h: In function ‘void std::swap(_Tp&, _Tp&) [with
_Tp = __gnu_cxx::temporary_buffer<char*>]’:
tmpswap.cpp:7:22:   instantiated from here
/usr/include/c++/4.6/bits/move.h:128:7: note: synthesized method
‘__gnu_cxx::temporary_buffer<char*>&
__gnu_cxx::temporary_buffer<char*>::operator=(const
__gnu_cxx::temporary_buffer<char*>&)’ first required here


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug libstdc++/52442] temporary_buffer does not swap
  2012-02-29 21:20 [Bug libstdc++/52442] New: temporary_buffer does not swap giecrilj at stegny dot 2a.pl
@ 2012-02-29 22:10 ` redi at gcc dot gnu.org
  2012-02-29 23:25 ` giecrilj at stegny dot 2a.pl
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: redi at gcc dot gnu.org @ 2012-02-29 22:10 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52442

--- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> 2012-02-29 21:44:21 UTC ---
You're right, it can't be used like that, but it's not meant to be.

By design temporary_buffer is not copyable, so it's not swappable either.


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug libstdc++/52442] temporary_buffer does not swap
  2012-02-29 21:20 [Bug libstdc++/52442] New: temporary_buffer does not swap giecrilj at stegny dot 2a.pl
  2012-02-29 22:10 ` [Bug libstdc++/52442] " redi at gcc dot gnu.org
  2012-02-29 23:25 ` giecrilj at stegny dot 2a.pl
@ 2012-02-29 23:25 ` giecrilj at stegny dot 2a.pl
  2012-03-01  0:30 ` redi at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: giecrilj at stegny dot 2a.pl @ 2012-02-29 23:25 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52442

--- Comment #2 from Christopher Yeleighton <giecrilj at stegny dot 2a.pl> 2012-02-29 23:23:34 UTC ---
(In reply to comment #1)
> You're right, it can't be used like that, but it's not meant to be.
> 
> By design temporary_buffer is not copyable, so it's not swappable either.

Here is my shoot, feel free to criticise.  Not copyable but swappable.


template < class P_T > 
class temporary_buffer: protected ::std ::pair < P_T *, ::std ::ptrdiff_t > 
{ 
    public: typedef P_T item_type; 
    public: typedef class temporary_buffer < item_type > itself, &ref; typedef
itself const &cref;
    public: typedef class ::std ::pair < item_type *, ::std ::ptrdiff_t >
inherited; 
    public: typedef typename inherited ::second_type size_type;
    public: 
    temporary_buffer (::std ::ptrdiff_t const &p_s = 01)
    : inherited (::std ::get_temporary_buffer < item_type >(p_s)) {} 
    private: temporary_buffer (cref); ref operator = (cref);
    public: ~temporary_buffer () { ::std ::return_temporary_buffer (inherited
::first); } 
    public: size_type const &size () const { return inherited ::second; } 
    public: item_type *const &buffer () const { return inherited ::first; }
    public: ref clear () { inherited ::second = size_type (); return *this; } 
    protected: inherited &base () { return *this; } 
    protected: inherited const &base () const { return *this; }
    public: void swap (ref that) { ::std ::swap (base (), that .base ()); }};


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug libstdc++/52442] temporary_buffer does not swap
  2012-02-29 21:20 [Bug libstdc++/52442] New: temporary_buffer does not swap giecrilj at stegny dot 2a.pl
  2012-02-29 22:10 ` [Bug libstdc++/52442] " redi at gcc dot gnu.org
@ 2012-02-29 23:25 ` giecrilj at stegny dot 2a.pl
  2012-02-29 23:25 ` giecrilj at stegny dot 2a.pl
  2012-03-01  0:30 ` redi at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: giecrilj at stegny dot 2a.pl @ 2012-02-29 23:25 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52442

--- Comment #3 from Christopher Yeleighton <giecrilj at stegny dot 2a.pl> 2012-02-29 23:25:19 UTC ---
(In reply to comment #1)
> You're right, it can't be used like that, but it's not meant to be.
> 
> By design temporary_buffer is not copyable, so it's not swappable either.

Here is my shoot, feel free to criticise.  Not copyable but swappable.


template < class P_T > 
class temporary_buffer: protected ::std ::pair < P_T *, ::std ::ptrdiff_t > 
{ 
    public: typedef P_T item_type; 
    public: typedef class temporary_buffer < item_type > itself, &ref; typedef
itself const &cref;
    public: typedef class ::std ::pair < item_type *, ::std ::ptrdiff_t >
inherited; 
    public: typedef typename inherited ::second_type size_type;
    public: 
    temporary_buffer (::std ::ptrdiff_t const &p_s = 01)
    : inherited (::std ::get_temporary_buffer < item_type >(p_s)) {} 
    private: temporary_buffer (cref); ref operator = (cref);
    public: ~temporary_buffer () { ::std ::return_temporary_buffer (inherited
::first); } 
    public: size_type const &size () const { return inherited ::second; } 
    public: item_type *const &buffer () const { return inherited ::first; }
    public: ref clear () { inherited ::second = size_type (); return *this; } 
    protected: inherited &base () { return *this; } 
    protected: inherited const &base () const { return *this; }
    public: void swap (ref that) { ::std ::swap (base (), that .base ()); }};


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug libstdc++/52442] temporary_buffer does not swap
  2012-02-29 21:20 [Bug libstdc++/52442] New: temporary_buffer does not swap giecrilj at stegny dot 2a.pl
                   ` (2 preceding siblings ...)
  2012-02-29 23:25 ` giecrilj at stegny dot 2a.pl
@ 2012-03-01  0:30 ` redi at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: redi at gcc dot gnu.org @ 2012-03-01  0:30 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52442

--- Comment #4 from Jonathan Wakely <redi at gcc dot gnu.org> 2012-03-01 00:29:49 UTC ---
(In reply to comment #3)
> Here is my shoot, feel free to criticise.

It's formatted bizarrely and hurts my eyes ;)


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2012-03-01  0:30 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-02-29 21:20 [Bug libstdc++/52442] New: temporary_buffer does not swap giecrilj at stegny dot 2a.pl
2012-02-29 22:10 ` [Bug libstdc++/52442] " redi at gcc dot gnu.org
2012-02-29 23:25 ` giecrilj at stegny dot 2a.pl
2012-02-29 23:25 ` giecrilj at stegny dot 2a.pl
2012-03-01  0:30 ` redi at gcc dot gnu.org

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).