Skip to content

Commit

Permalink
fix #65
Browse files Browse the repository at this point in the history
  • Loading branch information
cmazakas committed Sep 30, 2024
1 parent 1359900 commit 0ae61d6
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 0 deletions.
2 changes: 2 additions & 0 deletions libsafecxx/single-header/std2.h
Original file line number Diff line number Diff line change
Expand Up @@ -827,6 +827,8 @@ box
{
}

box(box const^) = delete;

[[unsafe::drop_only(T)]]
~box() safe {
delete p_;
Expand Down
1 change: 1 addition & 0 deletions libsafecxx/test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ add_test(NAME "safecxx-verify-headers" COMMAND "${CMAKE_COMMAND}" --build ${CMAK
safe_cxx_compile_fail_test(string_view1 "use of sv depends on expired loan")
safe_cxx_compile_fail_test(box_incomplete "class incomplete is incomplete")
safe_cxx_compile_fail_test(box1 "cannot convert prvalue int to std2::box<int>")
safe_cxx_compile_fail_test(box2 "call to deleted borrow constructor")
safe_cxx_compile_fail_test(arc1 "cannot convert prvalue int to std2::arc<int>")
safe_cxx_compile_fail_test(rc1 "cannot convert prvalue int to std2::rc<int>")
safe_cxx_compile_fail_test(unsafe_cell1 "cannot convert prvalue std2::box<int> to std2::unsafe_cell<std2::box<int>>")
Expand Down
13 changes: 13 additions & 0 deletions libsafecxx/test/compile-fail/box2.cxx
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// Copyright 2024 Christian Mazakas
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE.txt or copy at http://www.boost.org/LICENSE_1_0.txt)

#feature on safety

#include <std2.h>

int main()
{
std2::box<int> p(1234);
auto p2 = cpy p;
}

0 comments on commit 0ae61d6

Please sign in to comment.