Fix non-throwing operator new failure checks being optimized away.

This commit is contained in:
Jonas 'Sortie' Termansen 2022-04-16 22:24:32 +02:00
parent 4b376c7f16
commit 322c8317d6
6 changed files with 10 additions and 6 deletions

View File

@ -7,7 +7,7 @@ OPTLEVEL?=$(DEFAULT_OPTLEVEL)
CXXFLAGS?=$(OPTLEVEL)
CPPFLAGS:=$(CPPFLAGS) -DVERSIONSTR=\"$(VERSION)\"
CXXFLAGS:=$(CXXFLAGS) -Wall -Wextra -fno-exceptions -fno-rtti
CXXFLAGS:=$(CXXFLAGS) -Wall -Wextra -fno-exceptions -fno-rtti -fcheck-new
LIBS:=$(LIBS)

View File

@ -9,7 +9,7 @@ CFLAGS?=$(OPTLEVEL)
CXXFLAGS?=$(OPTLEVEL)
CFLAGS:=$(CFLAGS) -Wall -Wextra
CXXFLAGS:=$(CXXFLAGS) -Wall -Wextra -fno-exceptions -fno-rtti
CXXFLAGS:=$(CXXFLAGS) -Wall -Wextra -fno-exceptions -fno-rtti -fcheck-new
BINARIES:=\
asteroids \

View File

@ -13,7 +13,7 @@ CXXFLAGS?=$(OPTLEVEL)
CPPFLAGS:=$(CPPFLAGS) -I. -Iinclude -D__is_sortix_kernel
CXXFLAGS:=$(CXXFLAGS) -Wall -Wextra -ffreestanding -fbuiltin -std=gnu++11 \
-fno-exceptions -fno-rtti
-fno-exceptions -fno-rtti -fcheck-new
ifeq ($(PANIC_SHORT),1)
CPPFLAGS:=$(CPPFLAGS) -DPANIC_SHORT

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2011, 2012, 2013 Jonas 'Sortie' Termansen.
* Copyright (c) 2011, 2012, 2013, 2022 Jonas 'Sortie' Termansen.
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
@ -20,6 +20,10 @@
#include <stddef.h>
#include <stdlib.h>
#ifdef __clang__
#warning "security: -fcheck-new might not work on clang"
#endif
void* operator new(size_t size)
{
return malloc(size);

View File

@ -12,7 +12,7 @@ CPPINCLUDES=-Iinclude
CPPFLAGS=-D__is_sortix_libc $(CPPINCLUDES)
FLAGS=-Wall -Wextra -ffreestanding $(OPTLEVEL)
CFLAGS=-std=gnu11 -Wstrict-prototypes -Werror=implicit-function-declaration
CXXFLAGS=-std=gnu++11 -fno-exceptions -fno-rtti
CXXFLAGS=-std=gnu++11 -fno-exceptions -fno-rtti -fcheck-new
ASFLAGS=
FREEOBJS=\

View File

@ -7,7 +7,7 @@ include ../build-aux/dirs.mak
OPTLEVEL?=-g -O2
CXXFLAGS?=$(OPTLEVEL)
CXXFLAGS:=$(CXXFLAGS) -std=gnu++11 -Wall -Wextra -fno-exceptions -fno-rtti
CXXFLAGS:=$(CXXFLAGS) -std=gnu++11 -Wall -Wextra -fno-exceptions -fno-rtti -fcheck-new
BINARY:=trianglix