This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] Include <memory> from system.h (PR bootstrap/82610)


On October 23, 2017 4:15:17 PM GMT+02:00, David Malcolm <dmalcolm@redhat.com> wrote:
>On Mon, 2017-10-23 at 15:51 +0200, Richard Biener wrote:
>> On Mon, Oct 23, 2017 at 2:58 PM, David Malcolm <dmalcolm@redhat.com>
>> wrote:
>> > On Sun, 2017-10-22 at 09:28 +0200, Gerald Pfeifer wrote:
>> > > On Thu, 19 Oct 2017, David Malcolm wrote:
>> > > > > In file included from /scratch/tmp/gerald/gcc-
>> > > > > HEAD/gcc/unique-
>> > > > > ptr-tests.cc:23:
>> > > > > In file included from /scratch/tmp/gerald/gcc-
>> > > > > HEAD/gcc/../include/unique-ptr.h:77:
>> > > > > In file included from /usr/include/c++/v1/memory:629:
>> > > > > /usr/include/c++/v1/typeinfo:199:2: error: no member named
>> > > > > 'fancy_abort' in namespace 'std::__1'; did you mean simply
>> > > > > 'fancy_abort'?
>> > > > >         _VSTD::abort();
>> > > > >         ^~~~~~~
>> > > > > /usr/include/c++/v1/__config:390:15: note: expanded from
>> > > > > macro
>> > > > > '_VSTD'
>> > > > > #define _VSTD std::_LIBCPP_NAMESPACE
>> > > > 
>> > > > There seem to have been similar problems on OS X:
>> > > >   https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82610
>> > > 
>> > > Yes, I believe it's the same actually (unearthed by clang as
>> > > system
>> > > compiler).
>> > > 
>> > > > The proposed fix there is to include <memory> in system.h,
>> > > > which
>> > > > presumably would fix this also.
>> > > 
>> > > That appears to work around the bootstrap failure on my tester as
>> > > well.
>> > > 
>> > > How can we go about fixing this in the tree?
>> > > 
>> > > Gerald
>> > 
>> > Here's the patch by fxcoudert from the PR (plus a ChangeLog entry)
>> > 
>> > Successfully bootstrapped & regrtested on x86_64-pc-linux-gnu;
>> > reported by fxcoudert as fixing the issue on darwin and by
>> > Gerald as fixing the issue on "newer versions of FreeBSD that use
>> > clang 4.0 as system compiler".
>> > 
>> > OK for trunk?
>> 
>> Not entirely happy as unique-ptr.h doesn't use <memory> but well.
>
>I'm not sure I understand you here.
>
>include/unique-ptr.h has:
>
>  #if __cplusplus >= 201103
>
>  /* In C++11 mode, all we need is import the standard
>     std::unique_ptr.  */
>  template<typename T> using unique_ptr = std::unique_ptr<T>;
>
>  /* Pull in move as well.  */
>  using std::move;
>
>  #else /* C++11 */
>
>  ...etc..., most of the file, the pre-C++11 implementation
>
>So in C++11 and later it's using std::unique_ptr, for which, as I
>understand it <memory> is the standard include, e.g.: 
>http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2012/n3337.pdf
>says in (20.6.2 Header <memory> synopsis [memory.syn]):
>
>"The header <memory> defines several types and function templates that
>describe properties of pointers and pointer-like types, manage memory
>for containers and other template types, [...] The header also defines
>the templates unique_ptr, shared_ptr, weak_ptr, and various template
>functions that operate on objects of these types (20.7)."
>
>Would you prefer the includes of <memory> in gcc/system.h and
>include/unique-ptr.h to be guarded by #if __cplusplus >= 201103 ? (not
>sure if it works yet, but I can try it)

I guess so. But we have to make gdb happy as well. It really depends how much each TU grows with the extra (unneeded) include grows in C++11 and C++04 mode. 

Richard. 

>Thanks
>Dave
>
>
>> Ok to unbreak bootstrap.
>> 
>> Thanks,
>> Richard.
>> 
>> > Sorry again about the breakage.
>> > 
>> > gcc/ChangeLog:
>> >         PR bootstrap/82610
>> >         * system.h [__cplusplus]: Include <memory>.
>> > ---
>> >  gcc/system.h | 1 +
>> >  1 file changed, 1 insertion(+)
>> > 
>> > diff --git a/gcc/system.h b/gcc/system.h
>> > index f0664e9..d6e1637 100644
>> > --- a/gcc/system.h
>> > +++ b/gcc/system.h
>> > @@ -233,6 +233,7 @@ extern int errno;
>> >  # include <vector>
>> >  #endif
>> >  # include <cstring>
>> > +# include <memory>
>> >  # include <new>
>> >  # include <utility>
>> >  #endif
>> > --
>> > 1.8.5.3
>> > 


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]