public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "akim.demaille at gmail dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/58594] New: std::make_shared does not accept const types as parameters
Date: Wed, 02 Oct 2013 13:58:00 -0000	[thread overview]
Message-ID: <bug-58594-4@http.gcc.gnu.org/bugzilla/> (raw)

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

            Bug ID: 58594
           Summary: std::make_shared does not accept const types as
                    parameters
           Product: gcc
           Version: 4.9.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: akim.demaille at gmail dot com

The following piece of code works with 4.8, clang 3.3 and 3.4, but not 4.9.  I
expect the code to be right, and 4.9 to be wrong, but even if it were the
converse, the location is useless: it's the end of the translation unit, not
the location of the error.  It works if I remove the const.

Cheers!


$ cat foo.cc
#include <memory>

int
main()
{
  const int f = 42;
  auto fp = std::make_shared<const int>(f);
  return 51;
}
$ g++-mp-4.8 --version
g++-mp-4.8 (MacPorts gcc48 4.8.1_3) 4.8.1
Copyright (C) 2013 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.

$ g++-mp-4.8 -Wall -std=c++11 foo.cc
$ g++-mp-4.9 --version
g++-mp-4.9 (MacPorts gcc49 4.9-20130915_0) 4.9.0 20130915 (experimental)
Copyright (C) 2013 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.

$ g++-mp-4.9 -Wall -std=c++11 foo.cc
In file included from /opt/local/include/gcc49/c++/bits/shared_ptr.h:52:0,
                 from /opt/local/include/gcc49/c++/memory:82,
                 from foo.cc:1:
/opt/local/include/gcc49/c++/bits/shared_ptr_base.h: In instantiation of 'void*
std::_Sp_counted_ptr_inplace<_Tp, _Alloc, _Lp>::_M_get_deleter(const
std::type_info&) [with _Tp = const int; _Alloc = std::allocator<int>;
__gnu_cxx::_Lock_policy _Lp = (__gnu_cxx::_Lock_policy)2u]':
foo.cc:9:1:   required from here
/opt/local/include/gcc49/c++/bits/shared_ptr_base.h:462:58: error: invalid
conversion from 'const void*' to 'void*' [-fpermissive]
  return __ti == typeid(_Sp_make_shared_tag) ? _M_ptr() : nullptr;
                                                          ^

Cheers!


             reply	other threads:[~2013-10-02 13:58 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-10-02 13:58 akim.demaille at gmail dot com [this message]
2013-10-02 14:42 ` [Bug libstdc++/58594] " redi at gcc dot gnu.org
2013-10-02 19:55 ` [Bug libstdc++/58594] [4.9 Regression] " redi at gcc dot gnu.org
2013-10-02 19:56 ` redi at gcc dot gnu.org
2014-12-13  0:44 ` redi at gcc dot gnu.org

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-58594-4@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).