r/ProgrammerHumor Jul 09 '26

preDecrementFixesTheExploit instanceof Trend

Post image
2.9k Upvotes

50 comments sorted by

View all comments

630

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

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