Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

check for safety #23

Open
wants to merge 1 commit into
base: v1.x.x
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions dub.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
"lflags-posix": [ "-lstdc++" ],
"lflags-linux": [ "--export-dynamic" ],
"lflags-osx": [ "-export_dynamic" ],
"dflags" : [ "-fsanitize=address" ],
"preGenerateCommands-posix": [
"$PACKAGE_DIR/extras/cxx-wrapper.sh test",
],
Expand Down
16 changes: 16 additions & 0 deletions source/stdcpp/list.d
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,8 @@ extern(C++, class) struct list(Type, Allocator)

void sort(U)(U comp);

~this();

private struct node
{
node* prev;
Expand Down Expand Up @@ -277,6 +279,11 @@ extern(C++, class) struct list(Type, Allocator)

size_type unique(U)(U p);

~this()
{
_List_base!(value_type, allocator_type)._M_clear();
}

private struct node
{
node* prev;
Expand Down Expand Up @@ -576,3 +583,12 @@ version (CppRuntime_Clang)
void clear() nothrow;
}
}

version (CppRuntime_Gcc)
{
extern(C++, class) struct _List_base(T, Alloc)
{
/* so we can call it on the type */
static void _M_clear() nothrow;
}
}
10 changes: 9 additions & 1 deletion source/stdcpp/set.d
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ extern(C++, class) struct set(Key, compare, Alloc)
///
this(ref const set!(Key) __x, ref const allocator!(Key));
///
allocator_type get_allocator() const nothrow;
allocator_type get_allocator() const nothrow;
///
size_type size() const nothrow;
///
Expand Down Expand Up @@ -203,5 +203,13 @@ version (CppRuntime_Gcc)
inout(pointer) end() inout nothrow;

inout(pointer) find(const ref _Key __k) inout;

/*
* clang on linux only emits the base object dtor(D2)
* so we can safely force mangle it to that
* since the complete dtor(D1) calls D2 in its stack frame
*/
pragma(mangle, "_ZNSt8_Rb_treeIiiSt9_IdentityIiESt4lessIiESaIiEED2Ev")
~this();
}
}
2 changes: 2 additions & 0 deletions source/stdcpp/vector.d
Original file line number Diff line number Diff line change
Expand Up @@ -840,6 +840,8 @@ extern(D):
extern(C++) pointer begin() nothrow;

extern(C++) pointer end() nothrow;

extern(C++) ~this();
}
else version (CppRuntime_Clang)
{
Expand Down
Loading