#define i jThings to commit just before leaving your job
11–20 of 165 posts
Re: Things to commit just before leaving your job
#12#define volatile // this one is cool Oh wow. This literally sent a shiver down my spine. Imagine debugging that. Also love the randmoness based ones!
Will you explain what this would do?
Basically this removes the volatile keyword from your code and replaces it with... nothing.
If a variable is declared volatile, it disables compiler optimizations and signals the compiler that this variable can be modified at any time (e.g. by hardware or other threads). Omitting volatile can lead to nasty concurrency bugs (e.g. if the optimizer optimizes spin locks away). In the worst case, such bugs are extremely hard to reproduce (and thus debug) but lead to deadlocks and/or crashes in case they do occur.
Re: Things to commit just before leaving your job
#13If only we can get a rosettacode version of this in all languages. I bet trolls will coming out left and right. It would be pure evil.
Most languages don't have a purely textual and completely unsafe preprocessor running during the compilation process, so it would be quite hard.
Re: Things to commit just before leaving your job
#14 /* create memory leaks if compiled on April, 1st */
#define free(x) if(strncmp(__DATE__, "Apr 1", 6) != 0) free(x)
The random ones are just pure evil.Re: Things to commit just before leaving your job
#15Re: Things to commit just before leaving your job
#16 #define continue breakRe: Things to commit just before leaving your job
#17Earlier quoted context omitted.
Will you explain what this would do?
Of course :) Basically this removes the volatile keyword from your code and replaces it with... nothing. If a variable is declared volatile, it disables compiler optimizations and signals the compiler that this variable can be modified at any time (e.g. by hardware or other threads). Omitting volatile can lead to nasty concurrency bugs (e.g. if the optimizer optimizes spin locks away). In the worst case, such bugs ar…
Re: Things to commit just before leaving your job
#18Earlier quoted context omitted.
Will you explain what this would do?
Of course :) Basically this removes the volatile keyword from your code and replaces it with... nothing. If a variable is declared volatile, it disables compiler optimizations and signals the compiler that this variable can be modified at any time (e.g. by hardware or other threads). Omitting volatile can lead to nasty concurrency bugs (e.g. if the optimizer optimizes spin locks away). In the worst case, such bugs ar…
In C and C++, volatile is not intended and must not be used for synchronisation primitives, it is not a memory fence (so it does not force cache coherency and does not prevent operations reordering) and operations on volatile variables are not atomic. Its primary use case is memory-mapped IO (with a sub-use case of preventing eliding memory operations affected by inline assembly). If a lock is broken because `volatile` is disabled, it's probably incorrect in the first place.
All `volatile` does[0] is forbid elision of loads and stores.
[0] again in C or C++, Java and C# have completely different semantics
Re: Things to commit just before leaving your job
#19We've got a guy in the office that merges the past over the present all the time. He's not quitting but I imagine if you were to try to break things this would be a good way to do it.
I am curious - wouldn't your Version Control system catch this and warn him that "file xyz has changed since you last checked it out, ..." etc?
Re: Things to commit just before leaving your job
#20Perhaps the most enlightening (and actually useful) purpose of this file is to dramatize the glaring weakness in the c/c++ macro system. A proper macro system would not make it so easy to do this, shall we say, "evil", stuff :)
class Fixnum
def +(other)
self - other
end
end
10 + 3
>>> 7