-
-
Notifications
You must be signed in to change notification settings - Fork 424
qsort/bsearch compare function is not @nogc #779
Conversation
void* bsearch(in void* key, in void* base, size_t nmemb, size_t size, int function(in void*, in void*) compar); | ||
void qsort(void* base, size_t nmemb, size_t size, int function(in void*, in void*) compar); | ||
void* bsearch(in void* key, in void* base, size_t nmemb, size_t size, _compare_fp_t compar); | ||
void qsort(void* base, size_t nmemb, size_t size, _compare_fp_t compar); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How did I miss that? Grrr. The thing is, if dmd actually compiled the source to qsort, it would flag the call to compar. But being an extern function, it can't check it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's a similar issue if the compar function throws. qsort() may not be exception safe. I don't know that there is a solution, other than when calling external C functions you're on your own, as has always been the case.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I don't see a way to make them @nogc
either.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Basically the story of druntime
...
Auto-merge toggled on |
qsort/bsearch compare function is not @nogc
Misleading description. |
No description provided.