Skip to main content
Search type Search syntax
Tags [tag]
Exact "words here"
Author user:1234
user:me (yours)
Score score:3 (3+)
score:0 (none)
Answers answers:3 (3+)
answers:0 (none)
isaccepted:yes
hasaccepted:no
inquestion:1234
Views views:250
Code code:"if (foo != bar)"
Sections title:apples
body:"apples oranges"
URL url:"*.example.com"
Saves in:saves
Status closed:yes
duplicate:no
migrated:no
wiki:no
Types is:question
is:answer
Exclude -[tag]
-apples
For more details on advanced search visit our help page
Results tagged with
Search options not deleted user 16385

A popularity-contest is a competition where the answer with the highest vote tally (upvotes minus downvotes) wins. As these are frequently closed, read the tag info and post your challenge to the sandbox first.

48 votes

Weirdest way to produce a stack overflow

C++ at compile time template <unsigned N> struct S : S<N-1> {}; template <> struct S<0> {}; template struct S<-1>; $ g++ -c test.cc -ftemplate-depth=40000 g++: internal compiler error: Segmentat …
hvd's user avatar
  • 3,674
17 votes

Call a method without calling it

GNU C #include <stdio.h> #include <stdlib.h> void hello_world() { puts(__func__); exit(0); } int main() { goto *&hello_world; } This is very direct, but is certainly not a call to hello_wor …
hvd's user avatar
  • 3,674
108 votes
Accepted

Call a method without calling it

C #include <stdio.h> int puts(const char *str) { fputs("Hello, world!\n", stdout); } int main() { printf("Goodbye!\n"); } When compiled with GCC, the compiler replaces printf("Goodbye!\n") wi …
hvd's user avatar
  • 3,674
3 votes

"Creative" ways to determine if an array is sorted

C As a binary search only works on sorted arrays, to check if an array is sorted, all we need to do is verify that a binary search works for all elements of the array. If it fails to find any element …
hvd's user avatar
  • 3,674
21 votes

Execute prints backwards

C Trying to make defiance of the tips in the question as creative as possible: #include <stdio.h> #define print if (i == __LINE__) puts static unsigned i; int main(void) { while (--i) { print( …
hvd's user avatar
  • 3,674
40 votes

Code Romanization

C There are only so many Roman numerals, since 4000 and higher have no standard notation, and the preprocessor is a wonderful decompression tool, especially if you have no problems with the fact that …
hvd's user avatar
  • 3,674