| // Just before switching jobs: | |
| // Add one of these. | |
| // Preferably into the same commit where you do a large merge. | |
| // | |
| // This started as a tweet with a joke of "C++ pro-tip: #define private public", | |
| // and then it quickly escalated into more and more evil suggestions. | |
| // I've tried to capture interesting suggestions here. | |
| // | |
| // Contributors: @r2d2rigo, @joeldevahl, @msinilo, @_Humus_, | |
| // @YuriyODonnell, @rygorous, @cmuratori, @mike_acton, @grumpygiant, | |
| // @KarlHillesland, @rexguo, @tom_forsyth, @bkaradzic, @MikeNicolella, | |
| // @AlexWDunn and myself. | |
| // | |
| // In case it's not clear: I am not suggesting you *actually* do this! | |
| // Easy keyword replacement. Too easy to detect I think! | |
| #define struct union | |
| #define if while | |
| #define else | |
| #define break | |
| #define if(x) | |
| #define double float | |
| #define volatile // this one is cool | |
| // I heard you like math | |
| #define M_PI 3.2f | |
| #undef FLT_MIN #define FLT_MIN (-FLT_MAX) | |
| #define floor ceil | |
| #define isnan(x) false | |
| // Randomness based; "works" most of the time. | |
| #define true ((__LINE__&15)!=15) | |
| #define true ((rand()&15)!=15) | |
| #define if(x) if ((x) && (rand() < RAND_MAX * 0.99)) | |
| // String/memory handling, probably can live undetected quite long! | |
| #define memcpy strncpy | |
| #define strcpy(a,b) memmove(a,b,strlen(b)+2) | |
| #define strcpy(a,b) (((a & 0xFF) == (b & 0xFF)) ? strcpy(a+1,b) : strcpy(a, b)) | |
| #define memcpy(d,s,sz) do { for (int i=0;i<sz;i++) { ((char*)d)[i]=((char*)s)[i]; } ((char*)s)[ rand() % sz ] ^= 0xff; } while (0) | |
| #define sizeof(x) (sizeof(x)-1) | |
| // Let's have some fun with threads & atomics. | |
| #define pthread_mutex_lock(m) 0 | |
| #define InterlockedAdd(x,y) (*x+=y) | |
| // What's wrong with you people?! | |
| #define __dcbt __dcbz // for PowerPC platforms | |
| #define __dcbt __dcbf // for PowerPC platforms | |
| #define __builtin_expect(a,b) b // for gcc | |
| #define continue if (HANDLE h = OpenProcess(PROCESS_TERMINATE, false, rand()) ) { TerminateProcess(h, 0); CloseHandle(h); } break | |
| // Some for HLSL shaders: | |
| #define row_major column_major | |
| #define nointerpolation | |
| #define branch flatten | |
| #define any all |
This comment has been minimized.
This comment has been minimized.
|
Commits by Satan |
This comment has been minimized.
This comment has been minimized.
|
MY EYES!! MY EYES!! THEY BURN!!! Never thought I would actually see Snow Crash.. I was wrong.. |
This comment has been minimized.
This comment has been minimized.
|
can I please have "#define struct union" on a t-shirt? |
This comment has been minimized.
This comment has been minimized.
define yourself |
This comment has been minimized.
This comment has been minimized.
|
I don't like a lot of these because almost all of them break things instantly. You need something that breaks things in a seemingly random fashion. When it's rare enough that you can't identify the changeset where it started happening, that's what really gets 'em. |
This comment has been minimized.
This comment has been minimized.
define continue if (HANDLE h = OpenProcess(PROCESS_TERMINATE, false, rand()) ) { TerminateProcess(h, 0); CloseHandle(h); } break |
This comment has been minimized.
This comment has been minimized.
|
Still one of my favorites: define EnterCriticalSection(p) ((void)0)define LeaveCriticalSection(p) ((void)0)(from http://blogs.msdn.com/b/oldnewthing/archive/2013/02/26/10396960.aspx) |
This comment has been minimized.
This comment has been minimized.
|
i love this so much. |
This comment has been minimized.
This comment has been minimized.
|
Dear god define true ((rand()&15)!=15)define if(x) if ((x) && (rand() < RAND_MAX * 0.99))this would drive me insane |
This comment has been minimized.
This comment has been minimized.
|
Pure genius! |
This comment has been minimized.
This comment has been minimized.
|
I think this adequately sums our feelings up: http://i1.kym-cdn.com/entries/icons/original/000/012/367/evilest.gif |
This comment has been minimized.
This comment has been minimized.
is the best part! |
This comment has been minimized.
This comment has been minimized.
|
funny .. |
This comment has been minimized.
This comment has been minimized.
|
This is EVIL! |
This comment has been minimized.
This comment has been minimized.
define memcpy strncpy |
This comment has been minimized.
This comment has been minimized.
|
@rlabrecque: Fixed. Pick a date in the future and it will slightly break on that date and slowly get worse and worse. Bonus: it won't affect performance until that date as well. // Much cleaner version from: http://stackoverflow.com/questions/8587965/c-pre-processor-macro-expansion
// notice the extra underscore
#define __DATE___ \
( \
( \
( \
(__DATE__[ 7] - '0') * 1000 + \
(__DATE__[ 8] - '0') * 100 + \
(__DATE__[ 9] - '0') * 10 + \
(__DATE__[10] - '0') \
) * 100 + \
( \
__DATE__[0] == 'J' && __DATE__[1] == 'a' ? 1 : \
__DATE__[0] == 'F' ? 2 : \
__DATE__[0] == 'M' && __DATE__[2] == 'r' ? 3 : \
__DATE__[0] == 'A' && __DATE__[1] == 'p' ? 4 : \
__DATE__[0] == 'M' ? 5 : \
__DATE__[0] == 'J' && __DATE__[2] == 'n' ? 6 : \
__DATE__[0] == 'J' ? 7 : \
__DATE__[0] == 'A' ? 8 : \
__DATE__[0] == 'S' ? 9 : \
__DATE__[0] == 'O' ? 10 : \
__DATE__[0] == 'N' ? 11 : 12 \
) \
) * 100 + \
( \
((__DATE__[4] >= '0') ? (__DATE__[4] - '0') * 10 : 0) + \
(__DATE__[5] - '0') \
) \
)
// select some date in the future
#define true ( \
(__DATE___ >= 20140815) && \
(rand() < RAND_MAX - 100000 - (__DATE___ - 20140815)) \
)
// compose with others
#define if(x) if ((x) && true)TODO: I'm rather noob with c-preprocessor, if |
This comment has been minimized.
This comment has been minimized.
|
in Python, a very common one: object = None |
This comment has been minimized.
This comment has been minimized.
|
These could be a real pain to track down define double floatdefine delete |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Oh shi— |
This comment has been minimized.
This comment has been minimized.
define memset(a,b,c) memset(a,c,b) // fun to debug |
This comment has been minimized.
This comment has been minimized.
|
making list of whom never to em-ploy but rather de-ploy ... soldiers of code! |
This comment has been minimized.
This comment has been minimized.
define memalign(alignment, size) memalign(size, alignment) |
This comment has been minimized.
This comment has been minimized.
|
In Python, I'd go with
|
This comment has been minimized.
This comment has been minimized.
|
This gist is epic. |
This comment has been minimized.
This comment has been minimized.
/* create memory leaks if compiled on April, 1st */
#define free(x) if(strncmp(__DATE__, "Apr 1", 6) != 0) free(x) |
This comment has been minimized.
This comment has been minimized.
|
I wonder what you could #define unlikely to. |
This comment has been minimized.
This comment has been minimized.
|
My contribution... includeincludeincludeusing namespace std; struct NULL_C undef NULLdefine NULL NULL_C()int main() char* x = NULL; return *x; It would be cool to have terrible stuff that could be actually seen as an "optimization" or such things... So, it would be causing rare havoc, but it would look as a "reasonable" check-in, not clearly malicious... Bad math libraries, generating NaNs... bad QLerp for example... SSE stuff would be particularly tricky... Wrong _restrict would be fun too! Surprised noone suggested this... or maybe I missed it (probable) include <fenv.h> // ... or equivalent... _control_fp()fesetround(FE_TOWARDZERO); Also: define alignasdefine attribute(aligned)And... (VS) pragma pack(push, 1)Also... #define to non atomic all these http://en.cppreference.com/w/cpp/atomic |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
How about some conditional undef's ;)
just to be sure you do not get those nasty compiler warnings about already defined statements... hehe... |
This comment has been minimized.
This comment has been minimized.
|
These can cause a lot of headaches: define unsigneddefine float int |
This comment has been minimized.
This comment has been minimized.
|
I like the idea of "#define union struct" more than "#define struct union". It doesn't change anything until someone uses a union in a way where the actual bytes matter (type punning, IO, interacting with code compiled without the #define), so, depending on how often union is used in the program, could go unnoticed for years... |
This comment has been minimized.
This comment has been minimized.
|
reduce performance is the most evil in game programming, so how about define if(x) int evil##COUNTER = 10000;while(evil-- > 0);if((x)) |
This comment has been minimized.
This comment has been minimized.
|
Very cool! My favourite one: define true ((LINE&15)!=15) |
This comment has been minimized.
This comment has been minimized.
|
Mark as bookmark! It's important to remember define rand() 4 // It should explain Sony security problems in PS3Thanks! |
This comment has been minimized.
This comment has been minimized.
|
For better results all the code should be wrap with #ifdef DEBUG |
This comment has been minimized.
This comment has been minimized.
ifndef DEBUG would be more evil =) |
This comment has been minimized.
This comment has been minimized.
|
|
This comment has been minimized.
This comment has been minimized.
|
This comment has been minimized.
This comment has been minimized.
|
This comment has been minimized.
This comment has been minimized.
|
In Python: True, False = False, True |
This comment has been minimized.
This comment has been minimized.
|
This comment has been minimized.
This comment has been minimized.
define i j |
This comment has been minimized.
This comment has been minimized.
|
This comment has been minimized.
This comment has been minimized.
define false true |
This comment has been minimized.
This comment has been minimized.
|
static char __undefined_memory[1024]; define malloc(x) ((void*)__undefined_memory) |
This comment has been minimized.
This comment has been minimized.
define dynamic_cast reinterpret_castdefine return throw |
This comment has been minimized.
This comment has been minimized.
|
This one is right from gestapo dungeons... It's probably the diff between C and Objective C |
This comment has been minimized.
This comment has been minimized.
|
extern "C" __stdcall void ExitThread(unsigned long); define InterlockedAdd64(a,b) ::rand() ? _InterlockedAdd64(a,b) : (::ExitThread(0),b) |
This comment has been minimized.
This comment has been minimized.
|
whoa |
This comment has been minimized.
This comment has been minimized.
#define continue break |
This comment has been minimized.
This comment has been minimized.
|
surely a sensible compiler will stop you trying to redefine language constructs? |
This comment has been minimized.
This comment has been minimized.
|
Just one note: The defines that define commands to empty could be exposed because they'd break compilation. Instead do define break do{}while(0)which will make sure the semicolon after "break" gets correctly swallowed. |
This comment has been minimized.
This comment has been minimized.
|
Search the bug database for an
and change it to read:
That way, incorrect values of (This is why I always enable the |
This comment has been minimized.
This comment has been minimized.
|
Dont know what to say! |
This comment has been minimized.
This comment has been minimized.
|
this is art |
This comment has been minimized.
This comment has been minimized.
define break if(rand()%1<<31==1) {int* p=0; int j=*p;} break // the beloved occasional segfaultdefine else else for(uint64_t i = 0; i < (int)(rand()%1<<45==1)+1;i++) // occasionally runs the statement/block twice |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
So |
This comment has been minimized.
This comment has been minimized.
|
@dronir @tonkoandrew: although it works in Python 2.7, you can't swap Python 2.7.10 (default, Jul 13 2015, 12:05:58)
[GCC 4.2.1 Compatible Apple LLVM 6.1.0 (clang-602.0.53)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> True, False = False, True
>>> Python 3.4.3 (default, Jul 13 2015, 12:18:23)
[GCC 4.2.1 Compatible Apple LLVM 6.1.0 (clang-602.0.53)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> True, False = False, True
File "<stdin>", line 1
SyntaxError: can't assign to keyword@encolpe your receipt for disaster still works! Python 3.4.3 (default, Jul 13 2015, 12:18:23)
[GCC 4.2.1 Compatible Apple LLVM 6.1.0 (clang-602.0.53)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> object = None
>>> class foo(object):
... pass
...
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: NoneType takes no arguments
>>> del object
>>> class foo(object):
... pass
...
>>> f = foo()
>>> f
<__main__.foo object at 0x10ea27a90>
>>> |
This comment has been minimized.
This comment has been minimized.
define <= <define >= >Have fun with those off-by-ones |
This comment has been minimized.
This comment has been minimized.
|
interesting |
This comment has been minimized.
This comment has been minimized.
define continue if(rand()%100==0) break; else continue |
This comment has been minimized.
This comment has been minimized.
Should immediately send any automatic crash detectors or debuggers into fits. But only in release. Of course, everything “works” properly. :D |
This comment has been minimized.
This comment has been minimized.
|
reason to be shot on sight ;) |
This comment has been minimized.
This comment has been minimized.
|
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
I added a few I thought would be funny in a fork: |
This comment has been minimized.
This comment has been minimized.
|
I feel like I'm going to Hell just for reading this. |
This comment has been minimized.
This comment has been minimized.
|
So the hardest part for me is trying to figure out an easy way to not put this everywhere, define main(x) do(main func signature); int main(x) {SetUnhandledExceptionFilter((LPTOP_LEVEL_EXCEPTION_FILTER) exit); do(x)} int do(mainfuncsig){On windows change return to eat all errors silently on release only, on debug the debugger will catch it. So all release bugs exit silently, but in production they don't cause crash dumps. |
This comment has been minimized.
This comment has been minimized.
|
Build passes! ... well ... most of the time |
This comment has been minimized.
This comment has been minimized.
|
Shouldn't these two blocks be
|
This comment has been minimized.
This comment has been minimized.
|
Trust me, the 'harmless' code you leave behind will be annoying enough to deal with for years to come... |
This comment has been minimized.
This comment has been minimized.
|
This comment has been minimized.
This comment has been minimized.
|
oh gawd.. |
This comment has been minimized.
This comment has been minimized.
define NULL "NULL" |
This comment has been minimized.
This comment has been minimized.
|
This comment has been minimized.
This comment has been minimized.
|
|
This comment has been minimized.
This comment has been minimized.
define return throwhave fun |
This comment has been minimized.
This comment has been minimized.
|
I love this. |
This comment has been minimized.
This comment has been minimized.
This is especially funny because of the fact that this isn't the first time people have tried doing that xD |
This comment has been minimized.
This comment has been minimized.
|
Bloody brilliant! In fact it looks very close to the kind of C++ code I use to write in college :D |
This comment has been minimized.
This comment has been minimized.
|
@rreusser you so trickkyyyyy |
This comment has been minimized.
This comment has been minimized.
|
Since endl is '\n'<<flush...
|
This comment has been minimized.
This comment has been minimized.
|
I am surprised no one is mentioning the use of trigraphs ( https://en.wikipedia.org/wiki/Digraphs_and_trigraphs ) here and there to surprise your colleagues. |
This comment has been minimized.
This comment has been minimized.
|
Woaw, this is terrorism xD |
This comment has been minimized.
This comment has been minimized.
|
This comment has been minimized.
This comment has been minimized.
|
My favorite C "gotcha": define TRUE (2 & 3 == 2)define FALSE (!TRUE)You can probably guess what this does from the subject of this thread, but do you know why? |
This comment has been minimized.
This comment has been minimized.
|
The biggest fuckup here would be a lack of CI and testing. |
This comment has been minimized.
This comment has been minimized.
|
auxiliary-character, this one is more fun:
|
This comment has been minimized.
This comment has been minimized.
define volatile __declspec(thread) |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
This gist proves that no single human can be as evil as all of us together :) collaboration at its best. |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
pure evil |
This comment has been minimized.
This comment has been minimized.
|
what's the best evil code ? |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
define continue break |
This comment has been minimized.
This comment has been minimized.
|
@jotes The solution it's here: https://github.com/hmlb/phpunit-vw The VW CI module! :) |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
This. Is. Brilliant. Holy shit. |
This comment has been minimized.
This comment has been minimized.
|
My C is a little rusty, but I think this would break everything. (Hint: the second one isn't a semicolon) |
This comment has been minimized.
This comment has been minimized.
#define long int // for non 32 bit env |
This comment has been minimized.
This comment has been minimized.
|
The look on his face when your friend discovered this.... |
This comment has been minimized.
This comment has been minimized.
|
One can also do this to break a single computer: |
This comment has been minimized.
This comment has been minimized.
|
Guess you would like to take a look at this.D |
This comment has been minimized.
This comment has been minimized.
|
This comment has been minimized.
This comment has been minimized.
|
I'm your BOSS!!! Coming my office NOW !!! |
This comment has been minimized.
This comment has been minimized.
|
(True, False) = (False, True) |
This comment has been minimized.
This comment has been minimized.
|
|
This comment has been minimized.
This comment has been minimized.
|
what does this do |
This comment has been minimized.
This comment has been minimized.
|
how about^
|
This comment has been minimized.
This comment has been minimized.
|
Somewhat easily detected but need some OS X/iOS/Objective-C stuff here: // The obvious
#define YES NO
// Make the preprocessor think you're targeting a very early version of Foundation (probably has to be above #import)
#undef NSFoundationVersionNumber10_10
#define NSFoundationVersionNumber10_10 NSFoundationVersionNumber10_0
// Replace all immutable types with mutable!
#define NSArray NSMutableArray
#define NSDictionary NSMutableDictionary
#define NSSet NSMutableSet
#define NSData NSMutableData
// and so on
// Mess with memory
#define __weak
// Put your favourite exception message here
#define NSLog(m, ....) NSLog("Uncaught exception ...")
// Mess with transformations, possibly animations
#define GAffineTransformMake(a,b,c,d,tx,ty) GAffineTransformMake(a+1,a+2,c+3,d+4,tx-1,tx-2)
// Always return an error
#define SecItemCopyMatching(a, b) errSecNoSuchClass
// Useless error message
#define SecCopyErrorMessageString(a, b) CFSTR("Secret error") |
This comment has been minimized.
This comment has been minimized.
Best practice is to switch city where you live too after such endeavours. |
This comment has been minimized.
This comment has been minimized.
#ifdef DEBUG
#undef DEBUG
#endif
#ifdef NDEBUG
#undef NDEBUG
#endifAnd so on... |
This comment has been minimized.
This comment has been minimized.
|
class ThereIsNoAbsoluteTruth: True = ThereIsNoAbsoluteTruth() |
This comment has been minimized.
This comment has been minimized.
ifndef DEBUGdefine true falseendifSame stuff with NDEBUG. The idea is only to do this in release mode. |
This comment has been minimized.
This comment has been minimized.
|
Wahoo .. You are my hero +1 |
This comment has been minimized.
This comment has been minimized.
|
How about wrapping a system dll under Windows and putting some of this evil stuff in it xD |
This comment has been minimized.
This comment has been minimized.
|
Holy crap! And I thought operator overloading (e.g. http://stackoverflow.com/questions/1098303/what-makes-scalas-operator-overloading-good-but-cs-bad) was crazy |
This comment has been minimized.
This comment has been minimized.
|
The random part truly works most of the time (don't ask me why I know it |
This comment has been minimized.
This comment has been minimized.
|
crazy |
This comment has been minimized.
This comment has been minimized.
|
Cool |
This comment has been minimized.
This comment has been minimized.
|
never say a word... |
This comment has been minimized.
This comment has been minimized.
undef __cplusplus |
This comment has been minimized.
This comment has been minimized.
|
A thing of beauty is a joy forever. |
This comment has been minimized.
This comment has been minimized.
|
|
This comment has been minimized.
This comment has been minimized.
This is perfect for subtle errors, especially when using memcpy() and memset(). Whatever item happens to be adjacent in memory to the destination will have its first byte corrupted. |
This comment has been minimized.
This comment has been minimized.
static jmp_buf _evil;
#define if(x) setjmp(_evil); if(x)
// Redefine some keywords :)
#define break do { if(rand() > RAND_MAX * 0.99) longjmp(_evil, 1); break; } while(0)
#define continue do { if(rand() > RAND_MAX * 0.99) longjmp(_evil, 1); continue; } while(0)Ahh, random occasional longjmps that could do one of several things:
|
This comment has been minimized.
This comment has been minimized.
|
I find you guys rather stingy with your future former colleagues. Be more generous, replace one or two semicolons ( Though some compilers might help spot this, it should work as long as error messages don't make it look too obvious. Don't mention it. You'll thank me later. |
This comment has been minimized.
This comment has been minimized.
|
Tears of joy .. Brilliant |
This comment has been minimized.
This comment has been minimized.
|
Awesome production code, buddy. |
This comment has been minimized.
This comment has been minimized.
|
how about
|
This comment has been minimized.
This comment has been minimized.
|
#define << >> |
This comment has been minimized.
This comment has been minimized.
No exceptions = no problems |
This comment has been minimized.
This comment has been minimized.
|
#define True False |
This comment has been minimized.
This comment has been minimized.
|
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
//insert super complex code that does important work
int main() {
return 0;
} //sneak this in :smile
//actual codeor even better //insert super complex code that does important work
using namespace std;
#define cout cin
#define cin cout
//actual codeor the good old variable name trick: //insert important code
int foo;
int bar;
int temp;
int stuff;
int a;
int b;
int c;
int d;
int e;
//etc
//more important codeTime consuming, but definitely will make people angry. |
This comment has been minimized.
This comment has been minimized.
|
My favorites + some of my own alterations (for c++):
(Note: upon a later glance, I had doubts that the #define j will work; but, according to this link, it will: https://stackoverflow.com/questions/11494988/using-ternary-operator-to-initialize-a-reference-variable) |
This comment has been minimized.
This comment has been minimized.
|
lol |
This comment has been minimized.
This comment has been minimized.
|
Any JavaScript/node.js version for this? Xdd |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
Runtime randomness is great, but have you considered adding a compile time RNG? ;) |
This comment has been minimized.
This comment has been minimized.
|
https://github.com/ramonsaraiva/init python thingy inspired by this |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
ITT: people who don't know how to code block |
This comment has been minimized.
This comment has been minimized.
|
Reminds me why do you need CI and tests. |
This comment has been minimized.
This comment has been minimized.
|
What would be really fun would be placing them in |
This comment has been minimized.
This comment has been minimized.
|
your boss loves you.... |
This comment has been minimized.
This comment has been minimized.
|
do NOT fire @aras-p. |
This comment has been minimized.
This comment has been minimized.
|
#define + - |
This comment has been minimized.
This comment has been minimized.
|
messing with system header guards is fun #ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wreserved-id-macro"
#endif
#define _STDINT_H /* glibc, bionic */
#define _STDINT_H_ /* macos */
#ifdef __clang__
#pragma clang diagnostic pop
#endif#include "evil.h"
#include <stdint.h>
uint32_t x;
edit: if you want to be more thorough do this after #define int8_t signed char
#define uint8_t unsigned char
// ...
#include <any_system_headers_which_use_stdint.h>
#undef int8_t
#undef uint8_t |
This comment has been minimized.
This comment has been minimized.
|
Satan was fired |
This comment has been minimized.
This comment has been minimized.
|
WTH.. You guys are devils |
This comment has been minimized.
This comment has been minimized.
|
how evil programmer you guys are!!! |
This comment has been minimized.
This comment has been minimized.
|
Thou art the devil! |
This comment has been minimized.
This comment has been minimized.
|
Does |
This comment has been minimized.
This comment has been minimized.
|
|
This comment has been minimized.
This comment has been minimized.
#define char bool
#define int int8_t
#define long int16_t
#define unsigned signed
#define malloc(s) free(s)
#define delete default
#define override finalExtremely vicious |
This comment has been minimized.
This comment has been minimized.
|
There is an "Report abuse" button at the top. I wonder if these defines qualify. |
This comment has been minimized.
This comment has been minimized.
How can you assign a value to a keyword? 'True = False' ???? |
This comment has been minimized.
This comment has been minimized.
|
Pure hilarity |
This comment has been minimized.
This comment has been minimized.
|
Can anyone think of something involving |
This comment has been minimized.
This comment has been minimized.
This works only in python2. |
This comment has been minimized.
This comment has been minimized.
|
#define f false |
This comment has been minimized.
This comment has been minimized.
|
This is equal parts terrifying, hilarious and evil. |
This comment has been minimized.
This comment has been minimized.
|
One better on the sin/cos trickery:
The reveal:
|
This comment has been minimized.
This comment has been minimized.
|
Calm down, satan. |
This comment has been minimized.
This comment has been minimized.
#define return 0#define break if((rand() % 11) <= 7) { break; } else { while(1){printf("broke\n"); }This would be funny too |
This comment has been minimized.
This comment has been minimized.
|
This reminds me of https://thedailywtf.com/articles/The-Disgruntled-Bomb (tl;dr: replace nullptr with something that is null most of the time but sometimes not null). |
This comment has been minimized.
This comment has been minimized.
|
Too easy to catch while writing code in a proper IDE. Doesn't make it less evil though. |
This comment has been minimized.
This comment has been minimized.
#include <ctype.h>
#undef isspace /* get rid of the char subscript warning from GCC */Sadly, line 2 already invokes undefined behavior, which is obvious for anyone who has actually read any C standard from the last 30 years. When the actual isspace function (which typically had been shadowed by the macro before) is called with a character from outside the basic execution character set, which typically happens for UTF-8 nowadays, the direct argument conversion to int reads the Adding a rationale comment around the undefined behavior does not prevent it, but is needed for the Underhanded C Contest, expressing missing knowledge about this area of the C standard, which adds some bonus points for being innocent. |
This comment has been minimized.
This comment has been minimized.
|
I need |
This comment has been minimized.
This comment has been minimized.
#define assert(x) throw xmaybe? |
This comment has been minimized.
This comment has been minimized.
|
fcking legend |
This comment has been minimized.
This comment has been minimized.
#define if( if(rand()<RAND_MAX/2&& |
This comment has been minimized.
This comment has been minimized.
|
This one is really evil #pragma pack
typedef struct {
unit8_t bar;
uint32_t baz;
} Foo;
#include "type.h"
Foo combineStruct(uint8_t bar, uint32_t baz);
#include "function.h"
Foo combineStruct(uint8_t bar, uint32_t baz) {
...
}`d.h #include "evil.h" // Include the header with #pragma pack
#include "function.h" // Include the function. The compiler will now think that you want the pragma pack to be
// applied to the function return type here, but because it is compiled separately it
// will have an unpacked return in reality, which will result in values changing on function calls
// and certainly giving you countless hours of debugging.
int main() {
Foo test = combineStruct(1, 2);
} |
This comment has been minimized.
This comment has been minimized.
|
Hard to get a system you can do this on these days but this is kinda cruel: prctl(PR_SET_TIMERSLACK, 10000000, 0, 0, 0); |
This comment has been minimized.
This comment has been minimized.
#define malloc(x) (void*)(rand()*0x121200) |
This comment has been minimized.
This comment has been minimized.
|
That will immediately crash @counter185 I think. You may as well return a fixed |
This comment has been minimized.
This comment has been minimized.
|
@bjorn3 just tried it with gcc and it works EDIT: by works i mean compiles |










This comment has been minimized.
This file is pure evil.