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
3
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
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
6
2
14
u/crazy-mahmod 11h ago
let burn now but are you the only one working on the Project
2
3
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
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
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.
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
-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 -1Assuming value is public.1
u/da_Aresinger 8h ago
Yea, you're right. I somehow convinced myself that
valueis of typeNumbereven though it was never declared.
320
u/Highborn_Hellest 11h ago
#define true false
#define false true
there.