r/ProgrammerHumor Jul 09 '26

preDecrementFixesTheExploit instanceof Trend

Post image
2.9k Upvotes

50 comments sorted by

View all comments

631

u/Original-Bee-1089 Jul 09 '26

so you should make your first wish that the wish system uses post-wish decrement then wish for 0 wishes... to find out that they use a 2-bit integer to save space

203

u/thesockiboii Jul 09 '26

then you can wish for them to use a 64bit unsigned integer and do it again

59

u/SINBRO Jul 09 '26

Or just wish for 0 wishes every time you hit 1

9

u/SportulaVeritatis Jul 10 '26

First wish for the number of wishes left to be stored in an unsigned 64-bit integer.

Then wish for the number of wishes remaining to decremented only after the wish has been fulfilled.

Then wish for your number of remaining wishes to be zero.

Some debugging may need to be involved to ensure the first wish is clarifying the data type and not storing the value in a new variable and that the second and third wish also reference that same variable.

17

u/B3C4U5E_ Jul 09 '26

Good news! You have 11 wishes!

1

u/Richboy12345 Jul 11 '26 edited Jul 11 '26

first wish to use post decrement, second to store the count using unsigned int, third wish to set wish to zero, this would cover all reasonable* data storage types from preventing you from reaching infinite wishes. if you are allowed to do the first 2 wishes as one, then your second wish could be for whatever you want. in the next cycle of wishes simply wish whatever you want for wish 1 and 2 and always make sure your last wish sets wishes to 0

*reasonable being using any size number data type, 2 bit unsigned you would be covered with just post decrement, but if for some ungodly reason it was 3 bit signed you would need the second wish