Skip to content

Commit 1dc6696

Browse files
vtzcursoragent
andcommitted
fix(platform): mark malloc_trap operator new as noexcept
GCC with -Werror rejects operator new returning nullptr unless declared noexcept/throw(). Since these trap functions always call abort(), the noexcept specification is correct and silences the diagnostic. Co-authored-by: Cursor <cursoragent@cursor.com>
1 parent ce164e3 commit 1dc6696

1 file changed

Lines changed: 2 additions & 4 deletions

File tree

src/platform/static/malloc_trap.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,18 +68,16 @@ void* realloc(void* ptr, size_t size) {
6868

6969
// NOLINTBEGIN(cert-dcl58-cpp,misc-new-delete-overloads)
7070

71-
void* operator new(std::size_t size) {
71+
void* operator new(std::size_t size) noexcept {
7272
std::fprintf(stderr,
7373
"MALLOC TRAP: operator new(%zu) detected\n", size);
7474
std::abort();
75-
return nullptr;
7675
}
7776

78-
void* operator new[](std::size_t size) {
77+
void* operator new[](std::size_t size) noexcept {
7978
std::fprintf(stderr,
8079
"MALLOC TRAP: operator new[](%zu) detected\n", size);
8180
std::abort();
82-
return nullptr;
8381
}
8482

8583
void operator delete(void* ptr) noexcept {

0 commit comments

Comments
 (0)