Issue 77129
Summary [libc] bsearch, qsort, qsort_r declared noexcept incorrectly
Labels libc
Assignees
Reporter nickdesaulniers
    In our generated headers (`<build dir>/projects/libc/include/stdlib.h`) I see the following:

```c
void * bsearch(const void *, const void *, size_t, size_t, __bsearchcompare_t) __NOEXCEPT;
void qsort(void *, size_t, size_t, __qsortcompare_t) __NOEXCEPT;
void qsort_r(void *, size_t, size_t, __qsortrcompare_t, void *) __NOEXCEPT;
```

https://gcc.gnu.org/onlinedocs/gcc-6.1.0/gcc/Common-Function-Attributes.html#Common-Function-Attributes mentions:

```
nothrow
The nothrow attribute is used to inform the compiler that a function cannot throw an exception. For example, most functions in the standard C library can be guaranteed not to throw an exception with the notable exceptions of qsort and bsearch that take function pointer arguments.
```

I suspect the same logic applies for noexcept as it does nothrow.  I suspect getting this wrong can lead to codegen bugs in cases of C++ code compiled with exception support calling one of these functions, and passing a callback that does throw.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to