public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libstdc++/58839] New: Regression: dereferencing void in shared_ptr(unique_ptr&& u) constructor
@ 2013-10-22 10:23 mrlika at gmail dot com
  2013-10-22 11:30 ` [Bug libstdc++/58839] Regression: dereferencing void* " paolo.carlini at oracle dot com
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: mrlika at gmail dot com @ 2013-10-22 10:23 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 58839
           Summary: Regression: dereferencing void in
                    shared_ptr(unique_ptr&& u) constructor
           Product: gcc
           Version: 4.8.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libstdc++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: mrlika at gmail dot com

This completely valid C++11 code does not compile when T is void.

template <typename T>
void f() {
    std::unique_ptr<T> sp;
    std::shared_ptr<T> up(std::move(sp));
}

int main() {
    f<char>();
    //f<void>(); // Error /usr/include/c++/4.8/bits/shared_ptr_base.h:851:34:
error: ‘std::unique_ptr<void, std::default_delete<void> >::pointer {aka void*}’
is not a pointer-to-object type
}

This bug makes impossible to use shared_ptr constructor that takes unique_ptr
rvalue reference as a parameter with type of pointer T=void.

This is regression appeared after changing line in shared_ptr_base.h from

         _Tp1* __tmp = __r.get();

to

        auto __tmp = std::__addressof(*__r.get());

in the following commit:

2012-11-07     paolo    2012-11-07 Paolo Carlini <paolo.carlini@oracle.com>
>From gcc-bugs-return-432448-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Tue Oct 22 10:49:34 2013
Return-Path: <gcc-bugs-return-432448-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org>
Delivered-To: listarch-gcc-bugs@gcc.gnu.org
Received: (qmail 17335 invoked by alias); 22 Oct 2013 10:49:34 -0000
Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm
Precedence: bulk
List-Id: <gcc-bugs.gcc.gnu.org>
List-Archive: <http://gcc.gnu.org/ml/gcc-bugs/>
List-Post: <mailto:gcc-bugs@gcc.gnu.org>
List-Help: <mailto:gcc-bugs-help@gcc.gnu.org>
Sender: gcc-bugs-owner@gcc.gnu.org
Delivered-To: mailing list gcc-bugs@gcc.gnu.org
Received: (qmail 17312 invoked by uid 48); 22 Oct 2013 10:49:29 -0000
From: "bugzilla@poradnik-webmastera.com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug bootstrap/58840] New: Problem compiling gcc 4.7.3 using gcc 4.4.6
Date: Tue, 22 Oct 2013 10:49:00 -0000
X-Bugzilla-Reason: CC
X-Bugzilla-Type: new
X-Bugzilla-Watch-Reason: None
X-Bugzilla-Product: gcc
X-Bugzilla-Component: bootstrap
X-Bugzilla-Version: 4.7.3
X-Bugzilla-Keywords:
X-Bugzilla-Severity: normal
X-Bugzilla-Who: bugzilla@poradnik-webmastera.com
X-Bugzilla-Status: UNCONFIRMED
X-Bugzilla-Priority: P3
X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org
X-Bugzilla-Target-Milestone: ---
X-Bugzilla-Flags:
X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter
Message-ID: <bug-58840-4@http.gcc.gnu.org/bugzilla/>
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: 7bit
X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/
Auto-Submitted: auto-generated
MIME-Version: 1.0
X-SW-Source: 2013-10/txt/msg01592.txt.bz2
Content-length: 1222

http://gcc.gnu.org/bugzilla/show_bug.cgi?idX840

            Bug ID: 58840
           Summary: Problem compiling gcc 4.7.3 using gcc 4.4.6
           Product: gcc
           Version: 4.7.3
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: bootstrap
          Assignee: unassigned at gcc dot gnu.org
          Reporter: bugzilla@poradnik-webmastera.com

make[3]: Entering directory `[path]/gcc/obj/gcc'
build/gengtype  \
                    -S ../../gcc-4.7.3/gcc -I gtyp-input.list -w
tmp-gtype.state
../../gcc-4.7.3/gcc/../include/splay-tree.h:55: unidentified type `uintptr_t'
../../gcc-4.7.3/gcc/../include/splay-tree.h:56: unidentified type `uintptr_t'
make[3]: *** [s-gtype] Error 1
make[3]: Leaving directory `[path]/gcc/obj/gcc'
make[2]: *** [all-stage1-gcc] Error 2

GCC is configured in this way:
../gcc-4.7.3/configure --prefix=[myprefix] --enable-languages=c,c++
--disable-nls

Installed compiler:
gcc --version
gcc (GCC) 4.4.6 20110731 (Red Hat 4.4.6-3)
Copyright (C) 2010 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.


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

* [Bug libstdc++/58839] Regression: dereferencing void* in shared_ptr(unique_ptr&& u) constructor
  2013-10-22 10:23 [Bug libstdc++/58839] New: Regression: dereferencing void in shared_ptr(unique_ptr&& u) constructor mrlika at gmail dot com
@ 2013-10-22 11:30 ` paolo.carlini at oracle dot com
  2013-10-22 11:58 ` redi at gcc dot gnu.org
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: paolo.carlini at oracle dot com @ 2013-10-22 11:30 UTC (permalink / raw)
  To: gcc-bugs

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

Paolo Carlini <paolo.carlini at oracle dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jwakely.gcc at gmail dot com

--- Comment #1 from Paolo Carlini <paolo.carlini at oracle dot com> ---
However, you are wrong about the commit which changed that line:

  http://gcc.gnu.org/viewcvs/gcc?view=revision&revision=194651

Jon, can you have a look?


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

* [Bug libstdc++/58839] Regression: dereferencing void* in shared_ptr(unique_ptr&& u) constructor
  2013-10-22 10:23 [Bug libstdc++/58839] New: Regression: dereferencing void in shared_ptr(unique_ptr&& u) constructor mrlika at gmail dot com
  2013-10-22 11:30 ` [Bug libstdc++/58839] Regression: dereferencing void* " paolo.carlini at oracle dot com
@ 2013-10-22 11:58 ` redi at gcc dot gnu.org
  2013-10-24  8:42 ` mrlika at gmail dot com
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: redi at gcc dot gnu.org @ 2013-10-22 11:58 UTC (permalink / raw)
  To: gcc-bugs

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

Jonathan Wakely <redi at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |ASSIGNED
   Last reconfirmed|                            |2013-10-22
           Assignee|unassigned at gcc dot gnu.org      |redi at gcc dot gnu.org
     Ever confirmed|0                           |1


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

* [Bug libstdc++/58839] Regression: dereferencing void* in shared_ptr(unique_ptr&& u) constructor
  2013-10-22 10:23 [Bug libstdc++/58839] New: Regression: dereferencing void in shared_ptr(unique_ptr&& u) constructor mrlika at gmail dot com
  2013-10-22 11:30 ` [Bug libstdc++/58839] Regression: dereferencing void* " paolo.carlini at oracle dot com
  2013-10-22 11:58 ` redi at gcc dot gnu.org
@ 2013-10-24  8:42 ` mrlika at gmail dot com
  2013-10-24  9:02 ` paolo.carlini at oracle dot com
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: mrlika at gmail dot com @ 2013-10-24  8:42 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from Andriy Lysnevych <mrlika at gmail dot com> ---
Hi Paolo,

You are right. It is not yours commit but next one.

__r.get() returns T* and construction *__r.get() works for any type except the
case when T=void. It causes dereferencing of void pointer that is prohibited by
standard.
When code creates unique_ptr<void> a resource hidden behind void pointer (most
likely with custom deleter functionality) and then tries to pass it to
shared_ptr<void>(unique_ptr<void>&&) constructor we get this void dereferencing
error.

Regards


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

* [Bug libstdc++/58839] Regression: dereferencing void* in shared_ptr(unique_ptr&& u) constructor
  2013-10-22 10:23 [Bug libstdc++/58839] New: Regression: dereferencing void in shared_ptr(unique_ptr&& u) constructor mrlika at gmail dot com
                   ` (2 preceding siblings ...)
  2013-10-24  8:42 ` mrlika at gmail dot com
@ 2013-10-24  9:02 ` paolo.carlini at oracle dot com
  2013-10-29 21:33 ` [Bug libstdc++/58839] [4.8/4.9 Regression] " redi at gcc dot gnu.org
  2013-10-29 21:58 ` redi at gcc dot gnu.org
  5 siblings, 0 replies; 7+ messages in thread
From: paolo.carlini at oracle dot com @ 2013-10-24  9:02 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from Paolo Carlini <paolo.carlini at oracle dot com> ---
Yes, as you can see Jonathan is already on it.


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

* [Bug libstdc++/58839] [4.8/4.9 Regression] dereferencing void* in shared_ptr(unique_ptr&& u) constructor
  2013-10-22 10:23 [Bug libstdc++/58839] New: Regression: dereferencing void in shared_ptr(unique_ptr&& u) constructor mrlika at gmail dot com
                   ` (3 preceding siblings ...)
  2013-10-24  9:02 ` paolo.carlini at oracle dot com
@ 2013-10-29 21:33 ` redi at gcc dot gnu.org
  2013-10-29 21:58 ` redi at gcc dot gnu.org
  5 siblings, 0 replies; 7+ messages in thread
From: redi at gcc dot gnu.org @ 2013-10-29 21:33 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from Jonathan Wakely <redi at gcc dot gnu.org> ---
Author: redi
Date: Tue Oct 29 21:33:29 2013
New Revision: 204184

URL: http://gcc.gnu.org/viewcvs?rev=204184&root=gcc&view=rev
Log:
    PR libstdc++/58839
    * include/bits/shared_ptr_base.h
    (__shared_ptr<T>::__shared_ptr(unique_ptr<U,D>&&)): Only use addressof
    when unique_ptr<U,D>::pointer is not a built-in pointer type.
    * testsuite/20_util/shared_ptr/cons/58839.cc: New.
    * testsuite/20_util/enable_shared_from_this/members/assign.cc: New.
    * testsuite/20_util/enable_shared_from_this/members/unique_ptr.cc: New.

Added:
    trunk/libstdc++-v3/testsuite/20_util/enable_shared_from_this/members/
   
trunk/libstdc++-v3/testsuite/20_util/enable_shared_from_this/members/assign.cc
   
trunk/libstdc++-v3/testsuite/20_util/enable_shared_from_this/members/unique_ptr.cc
    trunk/libstdc++-v3/testsuite/20_util/shared_ptr/cons/58839.cc
Modified:
    trunk/libstdc++-v3/ChangeLog
    trunk/libstdc++-v3/include/bits/shared_ptr_base.h


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

* [Bug libstdc++/58839] [4.8/4.9 Regression] dereferencing void* in shared_ptr(unique_ptr&& u) constructor
  2013-10-22 10:23 [Bug libstdc++/58839] New: Regression: dereferencing void in shared_ptr(unique_ptr&& u) constructor mrlika at gmail dot com
                   ` (4 preceding siblings ...)
  2013-10-29 21:33 ` [Bug libstdc++/58839] [4.8/4.9 Regression] " redi at gcc dot gnu.org
@ 2013-10-29 21:58 ` redi at gcc dot gnu.org
  5 siblings, 0 replies; 7+ messages in thread
From: redi at gcc dot gnu.org @ 2013-10-29 21:58 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #5 from Jonathan Wakely <redi at gcc dot gnu.org> ---
Author: redi
Date: Tue Oct 29 21:58:27 2013
New Revision: 204186

URL: http://gcc.gnu.org/viewcvs?rev=204186&root=gcc&view=rev
Log:
    PR libstdc++/58839
    * include/bits/shared_ptr_base.h
    (__shared_ptr<T>::__shared_ptr(unique_ptr<U,D>&&)): Do not dereference
    pointer.
    * testsuite/20_util/shared_ptr/cons/58839.cc: New.

Added:
   
branches/gcc-4_8-branch/libstdc++-v3/testsuite/20_util/shared_ptr/cons/58839.cc
Modified:
    branches/gcc-4_8-branch/libstdc++-v3/ChangeLog
    branches/gcc-4_8-branch/libstdc++-v3/include/bits/shared_ptr_base.h


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

end of thread, other threads:[~2013-10-29 21:58 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-10-22 10:23 [Bug libstdc++/58839] New: Regression: dereferencing void in shared_ptr(unique_ptr&& u) constructor mrlika at gmail dot com
2013-10-22 11:30 ` [Bug libstdc++/58839] Regression: dereferencing void* " paolo.carlini at oracle dot com
2013-10-22 11:58 ` redi at gcc dot gnu.org
2013-10-24  8:42 ` mrlika at gmail dot com
2013-10-24  9:02 ` paolo.carlini at oracle dot com
2013-10-29 21:33 ` [Bug libstdc++/58839] [4.8/4.9 Regression] " redi at gcc dot gnu.org
2013-10-29 21:58 ` 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).