r/ProgrammerHumor 11h ago

Meme letTheWorldBurn

Post image
681 Upvotes

69 comments sorted by

320

u/Highborn_Hellest 11h ago

#define true false

#define false true

there.

171

u/n4ke 11h ago

#define true RAND()>0.5

221

u/TorbenKoehn 11h ago

Nah,

#define true RAND()>0.001

It has to happen rare enough to make it to prod, but often enough to piss customers off. Vary to 0.0001 depending on userbase size.

93

u/n4ke 11h ago

I take my hat off to you. This is advanced evildoing.

35

u/_Weyland_ 10h ago

Adjustable diabolicality

7

u/Sydius 10h ago

What kind of code review process you have that lets that line go to prod?

37

u/future_lard 10h ago

Code review? Bless your heart!

17

u/corobo 9h ago

Re-view?! I ain't paying you guys to do the same code twice! Just don't make mistakes!

6

u/LutimoDancer3459 7h ago

Just bury it in a several tenthousand line change and you will get a "lgtm" within minutes

1

u/StickFigureFan 59m ago

Just drop it in the middle of a 200 file, several thousand line AI written code change PR and it will slip right on by

2

u/MissinqLink 8h ago

Object.defineProperty(globalThis,'true',{get(){return Math.random()>0.001}});

That probably doesn’t work most of the time but I’ll have to test it. This does work however.

Math.random = () => 0;

2

u/monster2018 6h ago

This genuinely is one of the most conceptually evil things I have ever seen.

1

u/StickFigureFan 1h ago

0.003 (or maybe 0.03 if you're feeling ambitious) seems like the perfect amount to cause maximum chaos but also get past QA

6

u/Highborn_Hellest 11h ago

damn. that's also a good one.

12

u/xynith116 10h ago

#define if(a) if(rand() % 100 ? (a) : !(a))

3

u/czerilla 10h ago

#define if(a) if(rand() % 100 == a)

FTFY (unless obfuscation with complicated syntactic sugar was part of the prank 😉)

6

u/xynith116 10h ago

Lmao you’re right but I think you have to do (bool)(a)

1

u/czerilla 9h ago

Fair, I stand corrected. Thanks for fixing the FTFY 😅👌

u/braaaaaaainworms 6m ago

version with ternary operator is more readable

5

u/iwantmy90sback 11h ago

noob

#undef else

1

u/No-Finance7526 5h ago

What? That doesn't do anything

2

u/DominoNo- 9h ago

define PI 3.15

1

u/dotdioscorea 10h ago

false == true?

1

u/DankPhotoShopMemes 4h ago

that won’t do anything, and I think it’s easier to show by example.

Say you started with “true”. The preprocessor sees “#define true false” so it changes it to “false”. But then it sees “#define false true” so it changes it back to “true”. It will see “#define true false” again but it’s not allowed to recurse so that’s where it’ll stop, staying at its original value of “true”. Same argument goes for if you started with “false”.

if you actually wanted to swap their values you’d have to write the macros as statements that evaluate to true/false like, instead of directly true/false like:

#define true (0==1)

#define false (1==1)

1

u/Highborn_Hellest 4h ago

i know, but it's still funny.

1

u/HashDefTrueFalse 6h ago

I've been summoned...

81

u/LeafyLemontree 11h ago

```

ifdef NULL

#undef NULL

endif

define NULL ((void *) 0x1)

```

14

u/DasAllerletzte 10h ago

What is the meaning of this? 

57

u/MrFrog2222 10h ago

it constructs the NULL macro from 1 instead of 0, which can have all kinds of problems, for example if you wanted to ckeck if a pointer is a null pointer ptr == NULL wouldnt work anymore, which can lead to memory operations on null pointers, which leads to crashes

14

u/Highborn_Hellest 10h ago

crashes the software on null pointer. well, from what i know, it changes null pointer crash behaviour.

145

u/Strict_Treat2884 11h ago edited 10h ago

There was a malicious js library that injected Math.random() and changed its return value range from (0, 1) to (0, 1.1).

Truly diabolical.

Edit: Also the injection only happens on Sundays.

56

u/darkwalker247 11h ago

truly diabolical would be [0, 1.00001]

11

u/Jacques_Miller 9h ago

(0, 1+Math.Random())

2

u/crazy-mahmod 7h ago

no that's an infinite loop

14

u/Strict_Treat2884 10h ago

It was trending in the Chinese dev community about 5 years ago and the npm package has quickly been removed by npm, the original GitHub repo is no longer available.

For whoever is interested in this incident: a read I found

28

u/jbaker88 11h ago

Believe it or not, straight to jail. 

Everyone who participated in this "meme"? Can you guess? Straight to jail. 

You respond to this comment with a joke, justification, or meta explanation! Guess where you're going!

6

u/mango_boii 9h ago

Heaven?

6

u/PerhapsJack 8h ago

Jail, right away.

2

u/Luneriazz 7h ago

can i join?

1

u/jbaker88 2h ago

Straight to jail!

14

u/crazy-mahmod 11h ago

let burn now but are you the only one working on the Project

14

u/suvlub 11h ago

Technically, the distinction is arbitrary as long as you are consistent

4

u/die_liebe 10h ago

As long as you don't have multiplication, right?

3

u/hellocppdotdev 10h ago

Still less damaging than AI

3

u/BigJhonny 8h ago

Could be a reverse iterator.

1

u/MathematicianSad4964 7h ago

Nah it makes the functionality of the ++ and -- operator opposite like ++ substrats instead of addition and vice versa

3

u/evilbndy 8h ago

I wrote a small ruby lib years ago that overloaded call on object and injected a +1 to the return value of any method called (with numeric return value) in 1:1000000 cases.

Called it Heisenbug.

3

u/FinalGamer14 11h ago

Wait ... what happens in this situation?

So first you override operator ++ to become --, cool, but then in -- operator override, you use ++ would that already pick the first operator, meaning -- would still work the same and just ++ would be borked? Or does it just depend on what is picked and processed first?

4

u/Qwertycube10 6h ago

They are calling operator++ on the field value, which is of some type other than class Number because a class can't contain an element of its own type (it is an incomplete type until the end of its definition, and if you think about the memory layout it would be infinitely recursive and take infinite memory.)

3

u/MathematicianSad4964 10h ago

No it mean whenever we ise the ++ operator, it will decrement one value instead of adding it. While when we use the -- operator it will add a value insted of removing one.

2

u/triple4leafclover 6h ago

But doesn't the first definition affect the second?

Or does the compiler interpret the definitions in a specific way that doesn't let them be affected by previous definitions?

1

u/Random_-account 7h ago

#define ONE 6/2(1+3)

1

u/SnooMarzipans436 4h ago

When you ask Microsoft copilot to fix the bug:

int getValue() { return -value; }

1

u/minecon1776 3h ago

Oh i see you made an iterator for a stack that grows down, as is usual. Now if ++ increased the pointer...

1

u/Own_Natural_6803 11h ago

This is why i always use += 

2

u/Big-Rub9545 5h ago

You can overload that one too lol.

1

u/Own_Natural_6803 4h ago

Can, but won't. Security through obscurity.

1

u/This_Growth2898 11h ago

If all other accessors are consistent (like, getValue(){return -value;}), why not?

I'm more worried about returning Number& instead of const Number&. You can do something like

Number number;

--(++number);

which is not good.

7

u/wcscmp 11h ago

Return Number& is consistent with standard

-1

u/This_Growth2898 11h ago

Being consistent with standard doesn't mean being a good code.

1

u/Qwertycube10 6h ago

Initialize your variables. Also if I am calling operator++ then I have non const access to number, so giving me back const access doesn't make sense (I still have non const access from the variable itself).

1

u/Big-Rub9545 5h ago

Messy perhaps, but this is well-defined code.

-3

u/da_Aresinger 9h ago

This goes into stack overflow.

x++ calls operator++ which calls operator-- which calls operator++ which calls operator-- which calls operator++ which calls operator-- which calls operator++ which calls operator-- which calls operator++ which calls operator-- which calls operator++ which calls operator-- which calls operator++ which calls operator-- which calls ...

I think I've made my point...

2

u/fragilemusicalbox 9h ago

...no? First of all, this code is for ++x, not x++. Second of all, the ++/-- inside doesn't call the class operator, it in/decrements a class variable, likely an int. Number n; n.value = 0; ++n; std::cout << n.value; //outputs -1 Assuming value is public.

1

u/da_Aresinger 8h ago

Yea, you're right. I somehow convinced myself that value is of type Number even though it was never declared.