On Thu, 25 Jul 2013, Ted Unangst wrote:
Thanks, these are bugs worth fixing in any case, but the native gcc on
OpenBSD has these optimizations disabled. fyi. (it also has the ident
string feature disabled, fwiw.)
Indeed, good point for this particular case, though even gcc-4.2.1 (used
by OpenBSD) makes undefined behavior optimizations in other cases, such as
pointer overflow (see below).
As you mentioned, these bugs might be worth fixing anyway, in case OpenBSD
decides to support a compiler other than gcc-4.2.1 (perhaps a recent
version of Clang, which performs more aggressive optimizations).
Thanks,
Nickolai.
---
% cat t1.c
void foo(void);
void bar(char* p) {
if (p + 100 < p)
foo();
}
% uname -sr
OpenBSD 5.2
% gcc t1.c -S -o -
.file "t1.c"
.text
.globl bar
.type bar, @function
bar:
pushl %ebp
movl %esp, %ebp
popl %ebp
ret
.size bar, .-bar
%