A Guide to Undefined Behavior in C and C++ (2010)
blog.regehr.org
A Guide to Undefined Behavior in C and C++ (2010)
1–10 of 13 posts
Re: A Guide to Undefined Behavior in C and C++ (2010)
#2http://blog.llvm.org/2011/05/what-every-c-programmer-should-...
Re: A Guide to Undefined Behavior in C and C++ (2010)
#3Re: A Guide to Undefined Behavior in C and C++ (2010)
#4[deleted]
___
Isn't it undefined because of signed integer overflow? Or at least implementation defined whether it's undefined or not?
The C standard (n1570) even uses integer overflow as an example of undefined behavior in section 3.4.3
> An example of undefined behavior is the behavior on integer overflow
Re: A Guide to Undefined Behavior in C and C++ (2010)
#5[deleted]
Edit: I was responding to someone saying `(INT_MAX+1)` was implementation defined so couldn't go skynet; and I was asking honestly because the C standard is twisty as heck and maybe they knew something I didn't. ___ Isn't it undefined because of signed integer overflow? Or at least implementation defined whether it's undefined or not? The C standard (n1570) even uses integer overflow as an example of undefined behavi…
Re: A Guide to Undefined Behavior in C and C++ (2010)
#6I've been growing more skeptical of this claim over time. First, more evidence would be nice instead of "some loops". What is a program (not a benchmark) that has an observable performance difference when compiled with and without -fwrap?
Second, it seems counter productive. The word is now out that if you use signed ints, the compiler is going to fuck you over. So now everybody is (or should be) using unsigned ints, and whatever optimization the compiler was performing, now it can't. A lot of grief for no progress.
Re: A Guide to Undefined Behavior in C and C++ (2010)
#7> undefined behavior in C/C++ is that it simplifies the compiler’s job, making it possible to generate very efficient code in certain situations. I've been growing more skeptical of this claim over time. First, more evidence would be nice instead of "some loops". What is a program (not a benchmark) that has an observable performance difference when compiled with and without -fwrap? Second, it seems counter productive…
Google brings up this old message. It seems to affect the SPEC2000 suite fairly badly. SPEC2000 mostly measures real applications, such as gzip, and is not a series of microbenchmarks.
http://www.archivum.info/autoconf-patches@gnu.org/2007-01/00...
Re: A Guide to Undefined Behavior in C and C++ (2010)
#8> undefined behavior in C/C++ is that it simplifies the compiler’s job, making it possible to generate very efficient code in certain situations. I've been growing more skeptical of this claim over time. First, more evidence would be nice instead of "some loops". What is a program (not a benchmark) that has an observable performance difference when compiled with and without -fwrap? Second, it seems counter productive…
> I've been growing more skeptical of this claim over time. First, more evidence would be nice instead of "some loops". What is a program (not a benchmark) that has an observable performance difference when compiled with and without -fwrap? Google brings up this old message. It seems to affect the SPEC2000 suite fairly badly. SPEC2000 mostly measures real applications, such as gzip, and is not a series of microbenchm…
Re: A Guide to Undefined Behavior in C and C++ (2010)
#9> undefined behavior in C/C++ is that it simplifies the compiler’s job, making it possible to generate very efficient code in certain situations. I've been growing more skeptical of this claim over time. First, more evidence would be nice instead of "some loops". What is a program (not a benchmark) that has an observable performance difference when compiled with and without -fwrap? Second, it seems counter productive…
I've been vaguely concerned with how to ensure my C code avoids undefined behavior, but it didn't occur to me that I also need to watch out in being overly conservative because then I'll be causing the optimizers trouble.
I'm not trying to disparage anyone who is actually able to be productive in a C environment, but I'm really hoping something like Rust is able take over that development space.
Re: A Guide to Undefined Behavior in C and C++ (2010)
#10printf("INT_MAX+1= %lld\n", (long long)INT_MAX + 1LL);