diff options
author | Kartik K. Agaram <vc@akkartik.com> | 2016-06-02 09:15:40 -0700 |
---|---|---|
committer | Kartik K. Agaram <vc@akkartik.com> | 2016-06-02 09:15:40 -0700 |
commit | 2367988301704881a61ca12c23eda9c385c43d3e (patch) | |
tree | 613a6b3d8a3d25db89ee6944a524abfc32c1d4e1 | |
parent | e8eea70ab1f70822f756be3750817ac5e24bf24d (diff) | |
download | mu-2367988301704881a61ca12c23eda9c385c43d3e.tar.gz |
3026 - integer overflow protection
How did I not know about -ftrapv for so long?! Found while reading Memarian et al, "Into the depths of C: Elaborating the de facto standards". http://www.cl.cam.ac.uk/~pes20/cerberus/pldi16.pdf
-rw-r--r-- | 001help.cc | 4 | ||||
-rw-r--r-- | makefile | 2 |
2 files changed, 3 insertions, 3 deletions
diff --git a/001help.cc b/001help.cc index 1b24f217..b8dbe7a6 100644 --- a/001help.cc +++ b/001help.cc @@ -96,8 +96,8 @@ bool is_equal(char* s, const char* lit) { :(before "End Includes") #define SIZE(X) (assert((X).size() < (1LL<<(sizeof(int)*8-2))), static_cast<int>((X).size())) //: -//: 5. Integer overflow is still impossible to guard against. Maybe after -//: reading http://www.cs.utah.edu/~regehr/papers/overflow12.pdf +//: 5. Integer overflow is guarded against at runtime using the -ftrapv flag +//: to the compiler, supported by both GCC and LLVM. //: //: 6. Map's operator[] being non-const is fucking evil. :(before "Globals") // can't generate prototypes for these diff --git a/makefile b/makefile index cc0fd84c..626537d4 100644 --- a/makefile +++ b/makefile @@ -4,7 +4,7 @@ CXX ?= c++ CFLAGS ?= -g -O3 mu_bin: makefile mu.cc termbox/libtermbox.a - ${CXX} ${CFLAGS} -Wall -Wextra -fno-strict-aliasing mu.cc termbox/libtermbox.a -o mu_bin + ${CXX} ${CFLAGS} -Wall -Wextra -ftrapv -fno-strict-aliasing mu.cc termbox/libtermbox.a -o mu_bin # To see what the program looks like after all layers have been applied, read # mu.cc |