14
3
Your task is to generate a null-pointer exception. That is, your program must accept a value which it expects to be non-null, and throw an exception/error or crash because the value is null.
Furthermore, it can't be obvious from reading the code that the value is null. Your goal is to make it seem clear to the reader that the value is not null, even though it actually is.
- Instead of null, you can use nil, none, nothing, or whatever the equivalent is in your language. You can also use undefined, uninitialized, and so on.
- The problem with your code must be that the variable is (surprisingly) null where the program expects a non-null variable.
- Your program can respond to the null by throwing an exception, throwing an error, crashing, or whatever it normally does when an unexpected null is encountered.
This is a popularity contest, so be clever!
I'm closing this question because underhanded contests are off topic per community consensus.
– Dennis – 2016-11-19T20:57:49.833@Ourous Can you give an example to show what you mean? – Ypnypn – 2014-05-16T02:23:58.913
After looking over it, It's more of a cast error than what you're looking for. – Οurous – 2014-05-17T00:12:23.040
Am I allowed to use a compiler bug? – Mark – 2014-05-17T08:32:27.823
1@Mark It is a popularity contest; let the community decide. I'd definitely vote for a compiler bug. – 11684 – 2014-05-17T09:01:31.637