When the Compiler Bites
nullprogram.com
When the Compiler Bites
1–10 of 40 posts
Re: When the Compiler Bites
#2 volatile unsigned char *p = malloc(w * h);
...Re: When the Compiler Bites
#3 if (w == 0 || h
To me, that condition is just super-strange: if w is zero, the product w x h is zero too, so the entire allocation becomes pointless. Surely it should be: if (w != 0 && h
or something? Having these kinds of discussions based on code that is confusing in itself just becomes too much, for me.Re: When the Compiler Bites
#4I was once told that optimizations in the sense of dead code elimination the way clang does it could be bypassed by making a variable volatile... Wouldn't that help here as well? volatile unsigned char *p = malloc(w * h); ...
Re: When the Compiler Bites
#5This was interesting, but I don't get this part of the example code: if (w == 0 || h To me, that condition is just super-strange: if w is zero, the product w x h is zero too, so the entire allocation becomes pointless. Surely it should be: if (w != 0 && h or something? Having these kinds of discussions based on code that is confusing in itself just becomes too much, for me.
Re: When the Compiler Bites
#6As someone who has been reading compiler output for many years, it seems like these "flashes of inspiration" are relatively sparse compared to the bulk plain-stupid code they normally produce; once in a while you'll see something and think "that's clever... really clever", followed immediately by something so stupid it makes you wonder how it managed to generate such code. You can easily distinguish between that and human-written Asm that way. The latter may not have as much "peak cleverness" but certainly keeps up its average level of efficiency.
Re: When the Compiler Bites
#7I was once told that optimizations in the sense of dead code elimination the way clang does it could be bypassed by making a variable volatile... Wouldn't that help here as well? volatile unsigned char *p = malloc(w * h); ...
I tested it. It doesn't help on Clang.
Re: When the Compiler Bites
#8Re: When the Compiler Bites
#9[0] https://randomascii.wordpress.com/2012/02/25/comparing-float...
Re: When the Compiler Bites
#10This was interesting, but I don't get this part of the example code: if (w == 0 || h To me, that condition is just super-strange: if w is zero, the product w x h is zero too, so the entire allocation becomes pointless. Surely it should be: if (w != 0 && h or something? Having these kinds of discussions based on code that is confusing in itself just becomes too much, for me.