public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/58594] New: std::make_shared does not accept const types as parameters
@ 2013-10-02 13:58 akim.demaille at gmail dot com
  2013-10-02 14:42 ` [Bug libstdc++/58594] " redi at gcc dot gnu.org
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: akim.demaille at gmail dot com @ 2013-10-02 13:58 UTC (permalink / raw)
  To: gcc-bugs

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!


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

end of thread, other threads:[~2014-12-13  0:44 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-10-02 13:58 [Bug c++/58594] New: std::make_shared does not accept const types as parameters akim.demaille at gmail dot com
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

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