mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-08-05 09:20:29 +00:00
Causes cosmoc++ to segfault
cosmoc++ produces "internal compiler error: SIGSEGV" on this code if run via: mmake ctl/unique_ptr.o
This commit is contained in:
parent
d9b4f647d8
commit
fb0e2442ee
2 changed files with 50 additions and 0 deletions
19
ctl/unique_ptr.cc
Normal file
19
ctl/unique_ptr.cc
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
// -*- mode:c++; indent-tabs-mode:nil; c-basic-offset:4; coding:utf-8 -*-
|
||||||
|
// vi: set et ft=cpp ts=4 sts=4 sw=4 fenc=utf-8 :vi
|
||||||
|
//
|
||||||
|
// Copyright 2024 Justine Alexandra Roberts Tunney
|
||||||
|
//
|
||||||
|
// Permission to use, copy, modify, and/or distribute this software for
|
||||||
|
// any purpose with or without fee is hereby granted, provided that the
|
||||||
|
// above copyright notice and this permission notice appear in all copies.
|
||||||
|
//
|
||||||
|
// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
|
||||||
|
// WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
|
||||||
|
// WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
|
||||||
|
// AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
|
||||||
|
// DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
|
||||||
|
// PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
|
||||||
|
// TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
||||||
|
// PERFORMANCE OF THIS SOFTWARE.
|
||||||
|
|
||||||
|
#include "unique_ptr.h"
|
31
ctl/unique_ptr.h
Normal file
31
ctl/unique_ptr.h
Normal file
|
@ -0,0 +1,31 @@
|
||||||
|
// -*-mode:c++;indent-tabs-mode:nil;c-basic-offset:4;tab-width:8;coding:utf-8-*-
|
||||||
|
// vi: set et ft=cpp ts=4 sts=4 sw=4 fenc=utf-8 :vi
|
||||||
|
#ifndef COSMOPOLITAN_CTL_UNIQUE_PTR_H_
|
||||||
|
#define COSMOPOLITAN_CTL_UNIQUE_PTR_H_
|
||||||
|
#include <__utility/forward.h>
|
||||||
|
#include <__utility/move.h>
|
||||||
|
#include <__utility/swap.h>
|
||||||
|
|
||||||
|
namespace ctl {
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
using default_delete = decltype([](T* p) {
|
||||||
|
delete p;
|
||||||
|
});
|
||||||
|
|
||||||
|
template<typename T, typename D = default_delete<T>>
|
||||||
|
struct unique_ptr
|
||||||
|
{
|
||||||
|
T* p = 0;
|
||||||
|
|
||||||
|
using pointer = T*;
|
||||||
|
using element_type = T;
|
||||||
|
using deleter_type = D;
|
||||||
|
|
||||||
|
constexpr unique_ptr(nullptr_t = nullptr) { }
|
||||||
|
explicit unique_ptr(pointer p) : p(p) { }
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace ctl
|
||||||
|
#endif // COSMOPOLITAN_CTL_UNIQUE_PTR_H_
|
Loading…
Add table
Add a link
Reference in a new issue