Break some standards!
Python
print 'Hello World'
Explanation:
The standard of the Programming Puzzles & Code Golf Stack Exchange is to
Read the question carefully. What, specifically, is the question asking for? Make sure your answer provides that
This code is not answering the question, so it breaks the standard.
C
Here's a factorial program that compiles and runs succcessfully (with gcc4.6.3 on Ubuntu 12.04), but invokes as much undefined behaviour according to the C standard as I could cram in. Most are inspired from here. A lot of the remaining legal code is just bad.
int read(char** src, int into){
int _r; //leading underscores reserved, and
if (!--into) sscanf(*src,"%d",&into); //_r uninitalized
*(*(--src)+into)=_r>>360; //shifting more bits than we have
while (into-->0) (*src)[into]='.'; //modifying const char argv
printf(*src); // no return statement
}
main(int argc, const char** const argv){
union { int x; float y;} result;
int f,minus1=0xFFFFFFFF,r,a[]={0};
r=a[3]&2; //accessing past end of array
result.x=read(&argv[r],--r); //relying on order of arguments
for(f=*(int*)&result.y;f;f+=minus1) //type punning/invalid union access,
r*=f; //and unsigned overflow
printf("%d\n",(&r+2)[-2]); //negative array indexes
}
XHTML
<p>
<div></div>
</p>
The W3C specification (http://www.w3.org/TR/html-markup/p.html#p):
p – paragraph
The p element represents a paragraph.
Permitted contents
Phrasing content
Oh I feel dirty!
Edit: @xfix pointed out that the error I was displaying was actually XHTML. The HTML error this causes is cooler and less obvious such that:
<p><div></div><p>
becomes <p /><div></div></p>
because the <div>
causes the <p>
to self close. Thus resulting in an error because we are attempting to close a paragraph that doesn't exist.