Your task is simple. Write a program that should obviously produce an error on first glance either when compiled or run, but either doesn't or produces some other unrelated error. This is a popularity contest, so be creative.
|
C++Make sure you compile the following code in standard conforming mode (for example, for g++ use the -ansi flag):
How it works:
|
|||||||||||||
|
RubyAlways a fan of this one.
No
Here's a more mundane one that's gotten me before:
Prints "nothing to see here."
|
|||||
|
JavaScript
Here's how it works:
|
|||||||||||||||||||||
|
C?Pretty normal code here...
|
|||||||||||||||||||||
|
bash
Results
Explanation
|
|||||||||||||||||
|
JavaScriptWhen I was providing the following code I was told many times "It must be a typo! How can it work?".
The description below was copied exactly from one the recent cases.
|
|||||||||
|
Java
No stack overflows here; move along.
|
|||||||||||||||||||||
|
Perl
Source and explanation: http://stackoverflow.com/questions/11695110 |
|||||
|
VBA/VB6
Splitting an empty comma delimited string should give an empty array. Should be an obvious division by zero error, right?
|
|||||||||||||
|
C++
Why?
|
|||||
|
JavaProbably too obvious.
What?
|
|||||||||||||
|
C#
|
|||||||||
|
Objective-CNot a big deal, but it has surprised me while trying to put a link inside a comment:
|
|||||||||
|
JavaScript
How it works:
|
|||||||||||||||||||||
|
CoffeeScript
|
|||
|
PHP (40 bytes)
This was the answer I gave in this question: Insanity Check Program The idea was to make a code that produced errors. The 1st error that we will think of, is a syntax error. There are no syntax errors... Other would be that the class/function doesn't exist. It doesn't run that far... Other would be a time-out or a memory overflow, but, again, it doesn't reach that far... Test the code here: http://writecodeonline.com/php/ (remove the |
|||||||||||||||||
|
Javascript
Gives: 5 Whereas:
Gives SyntaxError How it works:
|
|||||||||
|
CStrings and arrays in c can be pretty confusing
|
|||||||||||||
|
Java
And how that one works:
And another one:
|
|||||||||||||||||||||
|
C
|
|||||||||||||||||||||
|
python
You expect
Instead you get
Also this:
|
|||||||||||||||||||||
|
VBScript
What it does:
|
|||
|
C++Mixing trigraphs and space-less lambdas can be quite confusing and definitely look erroneous to people who are not aware of trigraphs:
How it works:
|
|||||
|
First post here, I'm not sure I get this or not, but here goes.
|
|||||||||||||
|
Java
Why this works:
|
|||
|
Python
|
|||||
|
Java (java.util.regex.Pattern)This post's effectiveness depends on how much you know about
|
|||
|
C++How many times have you been told to be careful to avoid
|
|||||||||||||
|
PHPSome slightly non-standard syntax here:
What's going on?
|
|||
|
VBScriptVisual Basic 6 users will know that
is legal, as is
But what about
? Turns out that is legal in VBScript but not in VB6. Why?
|
|||||||||
|