[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [csmith-dev] feature request: generate memory unsafe code



On Tue, Jun 21, 2011 at 10:52 PM, John Regehr <regehr@cs.utah.edu> wrote:
> Actually, even so, the compiler can move the deref ahead of the system call.
>  Given the sloppy nature of undefined behavior in C, there's no general
> solution that I'm aware of.

Is that a problem in practice? We're only compiling and running the program
with the macros defined thus in order to obtain an oracle,
so we can disable optimizations for the compilation of that version.
GCC's documentation for the -g -O combination more or less implies that
without -O, the program is executed in the order it is written.
The compiler barrier solution listed in your post would also work: surely puts()
and fflush() touch some memory and cannot be moved across a memory barrier
even by a global optimization.

Pascal