g | x | w | all
Bytes Lang Time Link
018Typst240803T201650Zbb94
013Civet comptime240503T163633ZBbrk24
016Julia 1.0210818T112807ZMarcMush
025Nim210818T084905Zxigoi
nanC170522T211812ZMD XF
047Scala 3210604T195145Zuser
021TikZ pdfTeX 3.141592652.61.40.17170216T012115ZWheat Wi
018Rust170626T134110ZCensored
019PHP170522T210122ZMD XF
130MSBuild170216T113601ZDanko Du
078Java170216T111446ZOlivier
009gradle170220T135542ZMatias B
044GNU Make170217T194349ZDigital
138Haskell GHC170221T002923Zceased t
025Boo170220T162232ZMason Wh
nanHaskell ghc170219T161012ZProgram
016Factor170219T015750Zfede s.
021Clojure170216T034848ZCarcigen
033Mathematica 33 Bytes170216T210000ZKelly Lo
002Japt170216T200031ZETHprodu
015GNU Forth170216T084213Zzeppelin
009TeX170216T185212ZAndrew S
nanC++170216T101025Zbolov
034SWIProlog170216T082546ZFatalize
013Perl170216T013036Zuser6213
nanHaskell170216T125018Zuser2407
007GNU Makefile170216T084128ZArnauld
058C++170216T074224ZChristop
008Common Lisp170216T110328Zcoredump
018C170216T085716ZNeil

Typst, 18 bytes

#let f()=f()
#f()

Produces the following error:

$ typst c loop.typ
error: maximum function call depth exceeded
  ┌─ loop.typ:1:9
  │
1 │ #let f()=f()
  │          ^^^

help: error occurred in this call of function `f`
  ┌─ loop.typ:2:1
  │
2 │ #f()
  │  ^^^

Typst, 36 bytes

A solution that works without overflowing the stack.

#{let a=(1,);while a.len()>0{a+=a}}

Simpler solutions are detected as potentially infinite:

$ typst c loop.typ
error: condition is always true
  ┌─ loop.typ:1:7
  │
1 │ #while true{}
  │        ^^^^

$ typst c loop.typ
error: condition is always true
  ┌─ loop.typ:1:7
  │
1 │ #while 1 < 2{}
  │        ^^^^^

$ typst c loop.typ
error: loop seems to be infinite
  ┌─ loop.typ:2:1
  │
2 │ #while a>0{a+=1}}
  │  ^^^^^^^^^^^^^^^

$ typst c loop2.typ
error: loop seems to be infinite
  ┌─ loop2.typ:1:13
  │
1 │ #{let a=(1,);while a.len()>0{a.push(1)}}
  │              ^^^^^^^^^^^^^^^^^^^^^^^^^^

Civet --comptime, 13 bytes

comptime loop

When the --comptime flag is set, an expression or indented block preceded by the word comptime is evaluated at compile time. loop <statements> compiles to while (true) { <statements> }; since version 0.7.2, the number of statements may be zero.

Playground link. By default --comptime is not set for security reasons, and you need to check a box in the bottom right of the output to enable it. Do so at your own risk.

Julia 1.0, 16 bytes

@generated !x=!x

not a full program but a function, since Julia compiles functions the first time they are called

I'm pretty sure that's a compile-time infinite loop, since @code_llvm (which only compiles the function whithout executing it) also loops forever

Try it online!

Nim, 25 bytes

static:
 while 0<1:echo 2

Try it online!

Compile with --maxLoopIterationsVM:10000000000000000. The compiler on TIO is old and doesn't support this flag.

C, 31 bytes (16 + 15 for -mcmodel=medium)

main[-1llu]={1};

Inspired by Digital Trauma. Compile with the -mcmodel=medium flag.

Good luck compiling this, you'll need 1.8 yottabytes of RAM and disk space.

Scala 3, 47 bytes

type T[X]=X match{case 1=>T[X]}
val x:T[1]= ???

Try it in Scastie!

Terminates saying "Recursion limit exceeded."

TikZ (pdfTeX 3.14159265-2.6-1.40.17), 85 79 74 24 22 21 bytes

A bunch of bytes saved thanks to wchargin

One byte saved thanks to Chris H

\input tikz
\tikz\pic

I actually encountered this one by accident when I was working on homework. I spent quite a while waiting for it to compile before I realized what was happening.

This has two parts:

\input tikz

This loads the TikZ package

and:

\tikz\pic

This starts a \tikz environment and a draw command.

What is going on

The pdflatex compiler has trouble with \tikz\pic, and enters interactive mode causing it to stall indefinitely.

Rust, 18 bytes

include!(file!());

Classic self-include. Rustc is annoyingly sane though, and by default will bail out after 128 recursions, and it expands depth-first so exponential growth doesn't work either. The same applies to the C and C++ solutions though.

PHP, 19 bytes

<?include __FILE__;

MSBuild, 130 bytes

<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
    <Target Name="X">
        <Exec Command="msbuild"/>
    </Target>
</Project>

Save this as a file with .proj extension, and run with msbuild from the command prompt. MSBuild will run its only target which simply spawns another msbuild process.

Java, 102 95 89 88 78 bytes

class A<T>{}class B<T>extends A<A<?super B<B<T>>>>{A<?super B<A>>a=new B<>();}

This terminates with a StackOverflowError which happens because the generic resolution system can't decide a root against which to resolve the other generics.

Credits where due.

What happens here?

  1. A<T> is just there to have a 1-letter parent. It's generic. I could have used List, but the imports and repetition of 4 letters are too long.
  2. B<T> declares a basic generic.
  3. B extends A is required to have a hierarchy between B and A.
  4. extends A<A> creates a self reference on A<T>.
  5. A<? super B> triggers the lookup for generics on A<T>
  6. B<B<T>> creates a self-reference on B<T>.
  7. A<...> a=new B<>() forces the usage of the generics, instead of simply the definition of those, forcing the resolution when compiling B, and not afterwards.
  8. A<?super B creates a non-self-reference, so we have both a reference to one type and to another in the generics of A.
  9. B<A> creates a non-self-reference, so we have both a reference to one type and to another in the generics of B.

Now, the type A has generics type A and B, but which is to be chosen? Forget about self, let's try to resolve B. Ping.

Okay, B has generics type A and B, but which is to be chosen? Forget about self, let's try to resolve A. Pong.

This kind of recursion can't really be avoided because there are legitimate cases like A<B<A<B<A<B<Object>>>>>>: for example a JSON object: List<Map<String,Map<String,List<Map<String,List<String>>>>>>.

Compilation result

$ javac NoCompile.java


The system is out of resources.
Consult the following stack trace for details.
java.lang.StackOverflowError
        at com.sun.tools.javac.code.Types$UnaryVisitor.visit(Types.java:3260)
        at com.sun.tools.javac.code.Types$23.visitClassType(Types.java:2587)
        at com.sun.tools.javac.code.Types$23.visitClassType(Types.java:2579)
        at com.sun.tools.javac.code.Type$ClassType.accept(Type.java:554)
        at com.sun.tools.javac.code.Types$UnaryVisitor.visit(Types.java:3260)
        at com.sun.tools.javac.code.Types$23.visitClassType(Types.java:2592)
        at com.sun.tools.javac.code.Types$23.visitClassType(Types.java:2579)
        at com.sun.tools.javac.code.Type$ClassType.accept(Type.java:554)

On my system, the stack trace stops after showing 1024 lines, which are actually the 4 same lines repeated 256 times, thus proving an infinite recursion. I'll spare you that whole trace.

Savings

  1. 102 → 95 bytes: replaced interface+implements with class+extends.
  2. 95 → 89 bytes: replaced Long with A (twice).
  3. 89 → 88 bytes: used diamond operator (new B<A>()new B<>()) .
  4. 88 → 78 bytes: moved the variable declaration to a class member, thanks to VoteToClose.

gradle, 10 9 bytes

for(;;){}

with the above code placed in a build.gradle file. Gradle uses groovy as its base language so we are really talking about groovy here, but as the question was about build time I figured gradle would be more appropriate.

Running any gradle build commands with the above code prints the pointy-haired-boss-compatible build status line:

$ gradle tasks
> Configuring > 0/1 projects > root project

if you are aiming for a raise, add the debug -d flag for:

$ gradle -d tasks
14:56:25.522 [INFO] [org.gradle.internal.nativeintegration.services.NativeServices] Initialized native services in: .gradle/native
14:56:25.757 [DEBUG] [org.gradle.launcher.daemon.client.DaemonClient] Executing build 84908c0d-f28d-4c57-be61-40eaf0025e16.1 in daemon client {pid=27884}
14:56:25.761 [DEBUG] [org.gradle.internal.remote.internal.inet.InetAddresses] Adding IP addresses for network interface tun0
14:56:25.762 [DEBUG] [org.gradle.internal.remote.internal.inet.InetAddresses] Is this a loopback interface? false
14:56:25.762 [DEBUG] [org.gradle.internal.remote.internal.inet.InetAddresses] Is this a multicast interface? false
14:56:25.764 [DEBUG] [org.gradle.internal.remote.internal.inet.InetAddresses] Adding remote address /x:x:x:x:x:x:%tun0
14:56:25.764 [DEBUG] [org.gradle.internal.remote.internal.inet.InetAddresses] Adding remote address /x.x.x.x
14:56:25.764 [DEBUG] [org.gradle.internal.remote.internal.inet.InetAddresses] Adding IP addresses for network interface eth1
14:56:25.764 [DEBUG] [org.gradle.internal.remote.internal.inet.InetAddresses] Is this a loopback interface? false
14:56:25.764 [DEBUG] [org.gradle.internal.remote.internal.inet.InetAddresses] Is this a multicast interface? true
14:56:25.764 [DEBUG] [org.gradle.internal.remote.internal.inet.InetAddresses] Adding remote address /x:x:x:x:x:x:%eth1
14:56:25.764 [DEBUG] [org.gradle.internal.remote.internal.inet.InetAddresses] Adding remote address /x.x.x.x
14:56:25.764 [DEBUG] [org.gradle.internal.remote.internal.inet.InetAddresses] Adding remote multicast interface eth1
14:56:25.764 [DEBUG] [org.gradle.internal.remote.internal.inet.InetAddresses] Adding IP addresses for network interface lo
<snip>
14:57:07.055 [DEBUG] [org.gradle.cache.internal.DefaultFileLockManager] Releasing lock on daemon addresses registry.
14:57:07.056 [DEBUG] [org.gradle.cache.internal.DefaultFileLockManager] Waiting to acquire shared lock on daemon addresses registry.
14:57:07.056 [DEBUG] [org.gradle.cache.internal.DefaultFileLockManager] Lock acquired.
14:57:07.056 [DEBUG] [org.gradle.cache.internal.DefaultFileLockManager] Releasing lock on daemon addresses registry.
> Configuring > 0/1 projects > root project

which in addition to looking impressively complicated also updates with a new set of:

15:07:57.054 [DEBUG] [org.gradle.launcher.daemon.server.Daemon] DaemonExpirationPeriodicCheck running
15:07:57.054 [DEBUG] [org.gradle.cache.internal.DefaultFileLockManager] Waiting to acquire shared lock on daemon addresses registry.
15:07:57.054 [DEBUG] [org.gradle.cache.internal.DefaultFileLockManager] Lock acquired.
15:07:57.055 [DEBUG] [org.gradle.cache.internal.DefaultFileLockManager] Releasing lock on daemon addresses registry.
15:07:57.055 [DEBUG] [org.gradle.cache.internal.DefaultFileLockManager] Waiting to acquire shared lock on daemon addresses registry.
15:07:57.055 [DEBUG] [org.gradle.cache.internal.DefaultFileLockManager] Lock acquired.
15:07:57.055 [DEBUG] [org.gradle.cache.internal.DefaultFileLockManager] Releasing lock on daemon addresses registry.

status lines every 10 seconds making it look like the build is busy doing important technical...stuff.

GNU Make, 44

.PHONY:x
$(MAKEFILE_LIST):x;sleep 1;touch $@

I can't claim credit for this. It is derived from Robert Mecklenburg's book Managing Projects with GNU Make: The Power of GNU Make for Building Anything.

When make executes this makefile, it sees the makefile is out of date (because the .PHONY target is out of date, so it executes the touch command, which updates the timestamp of the makefile. Then make re-reads the file and discovers the makefile is out of date.... Well you get the idea.

I prefer this to the other Make answer because it does not use recursion. On my VM, the other Make answer continues forking processes and at somewhere around 7,000 deep, the VM grinds to an unresponsive halt. However, with this answer it is able to continue indefinitely without eating up system resources. You really will be able to slack off with this build. I've gone over 1,000,000 iterations with no apparent system degradation.

Note I had to add the sleep 1 so that the makefile timestamp is actually updated every time. You can change this to sleep 0.01 if you want it to burn through iterations a bit faster.

Haskell (GHC, without Template Haskell or custom rewrite rules), 138

{-#LANGUAGE FlexibleContexts,UndecidableInstances#-}
data A x=A
class C y where y::y
instance C(A(A x))=>C(A x)where y=A
main|A<-y=pure()

Theoretically, this enters an infinite loop in much the same way the C++ approach does: the polymorphic method y is instantiated to ever more convoluted types. In practice, the default allotted stack size actually overflows quickly:

$ ghc-7.10 wtmpf-file14146.hs 
[1 of 1] Compiling Main             ( wtmpf-file14146.hs, wtmpf-file14146.o )

wtmpf-file14146.hs:5:9:
    Context reduction stack overflow; size = 101
    Use -fcontext-stack=N to increase stack size to N
      C (A (A (A (A (A (A (A (A (A (A (A (A (A (A (A (A (A (A (A (A (A (A (A (A (A (A (A (A (A (A (A (A (A (A (A (A (A (A (A (A (A (A (A (A (A (A (A (A (A (A (A (A (A (A (A (A (A (A (A (A (A (A (A (A (A (A (A (A (A (A (A (A (A (A (A (A (A (A (A (A (A (A (A (A (A (A (A (A (A (A (A (A (A (A (A (A (A (A (A (A (A (A t0))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))
    In a stmt of a pattern guard for
                   an equation for ‘main’:
      A <- y
    In an equation for ‘main’: main | A <- y = pure ()

Credits to Luke Palmer.

Boo, 25 bytes

macro l:
 x=0 while 1>0
l

This defines a macro, which executes at compile time, which executes an infinite loop, and then invokes the macro.

Haskell (ghc), 32 + 2 = 34 bytes

{-#RULES""main=main#-}
main=main

run with ghc -O <file>. Triggers a rewrite rule for the main function which rewrites to the same thing. The only unfortunate feature is that ghc is smart enough to detect this and stop after 100 iterations. I don't know of an easy way to disable this behavior.

Factor, 29 16

<< [ t ] loop >>

The part between << >> is executed at parse time.

As for what [ t ] loop does, I'll let you guess...

You can put that in the Listener as is, or add it to any vocabulary or script file with the corresponding boilerplate stuff.

Clojure, 21 bytes

(defmacro a[]`(a))(a)

Ties up the compiler by defining a macro that repeatedly emits calls to itself.

On my phone, this causes the REPL to hang and lag the device. On my laptop, this fails outright with a StackOverflow.

Unfortunately the StackOverflow happens instantly, but it's still valid according to the rules.

Mathematica 33 Bytes

Compile[{},Evaluate@While[True,]]

The code will attempt to symbolically evaluate the argument prior to compilation, and the argument itself is an infinite loop. The While function has a null second argument since it's not important.

Japt, 2 bytes

`ÿ

You can test this online here, but I wouldn't recommend it as it will freeze your browser.

Explanation

Japt uses the shoco library for compressing strings. A backtick tells the compiler to decompress everything until the next backtick or the end of the file. Each byte does the following:

I don't believe there is any other way to mess with the Japt compiler, but you never know...

GNU Forth, 15 bytes

Golfed

: : [do] [loop]

Re-defines (re-compiles) the word : and invokes an immediate infinite loop [do] [loop] inside the new definition (right at the compile time).

One category of words don't get compiled. These so-called immediate words get executed (performed now) regardless of whether the text interpreter is interpreting or compiling.

Try It Online !

TeX, 9 bytes

\def~{~}~

TeX works by expanding macros. Most of the time, TeX's macros (also called control sequences) are of the form \name but it is also possible to define certain characters as macros, these are called active characters. The character ~ is active by default in plain TeX and so can be used as a macro name without further declaration. The \def~{~} in the above defines ~ so that it expands to ~. That is, whenever TeX encounters ~ then it replaces it by ~ and then re-examines the replacement, meaning that it encounters a wholly new occurrence of ~ and replaces that by ~. This defines the infinite loop. All that is then needed is to start the loop and that's what the final ~ does.


Added in edit

To make this properly compiled, invoke as:

pdftex -ini "&pdftex \def~{~}~"

The -ini flag says that pdftex should compile a new format file. This is a precompiled set of definitions which can be loaded when TeX is later invoked to speed up processing a document (LaTeX2e is an example of this). I guess that the &pdftex adds a few bytes, taking the total to 17.

C++, 37 30 29 bytes

int f(auto p){f(&p);},a=f(0);

It uses the future auto function parameter. It was proposed into C++17, but I don't think it made it. gcc however supports it as an extension.

Basically

void foo(auto p);

is equivalent to

template <class T>
void foo(T p);

The code tries to instantiate f recursively with different template arguments. gcc fails with

fatal error: template instantiation depth exceeds maximum of 900 (use -ftemplate-depth= to increase the maximum)

With -ftemplate-depth=10000 I got it to spit "Killed - processing time exceeded" on godbolt.

Check it on godbolt


1 byte saved by Quentin. Thank you.

SWI-Prolog, 34 bytes

term_expansion(_,_):-repeat,1=0.

Explanation

term_expansion/2 is something that gets called automatically by the compiler before actually compiling code to transform some terms in the source code into other terms.

Here, we introduce a new rule for term_expansion/2: repeat,1=0..

repeat/0 is a predicate which always succeeds, and provides an infinite number of choice points.

1=0 is trying to unify 1 with 0, which is always false. This will cause the compiler to backtrack to repeat (since it always provides a choice point) and try 1=0 again, etc.

Perl, 15 13 bytes

BEGIN{{redo}}

Try it online!

Now with 2 bytes saved: @Zaid reminded me of a terser way to do a loop in Perl.

This is pretty simple: it just installs a parser hook with an infinite loop in, making the code take infinitely long to parse. (Perl's nice in that it allows you to run arbitrary code in the middle of the parse; the parser hooks are specified in Perl itself, and frequently used to do things like import libraries or change the parsing rules for an identifier you want to treat like a keyword.) The Try it online! link above gives the -c option (to compile the code to verify the syntax for correctness, but not run it), to prove that the infinite loop happens at compile time.

In case you're wondering about "compile time" in a scripting language: Perl actually compiles to bytecode and then runs the bytecode, but this is a detail that's rarely relevant when programming it. The -MO= command line option family can be used to do things with the bytecode other than running it (although not with this program, as the infinite loop happens before the bytecode can be generated).

Haskell, 25+17=42 bytes

a= $(let a='a':a in[|a|])

A simple Haskell metaprogram which defines an infinite value and attempts to compute that value at compile time.

Invoke with ghc -XTemplateHaskell <file.hs> (+17 for the parameter to the compiler)

GNU Makefile, 8 7 bytes

One byte saved thanks to KonradRudolph

Saved as Makefile and invoked by make:

x:;make

This will produce an infinite build recursion on the first target found "x".

Needless to say that you don't really want to run this fork bomb on your production server. :-)

make
make[1]: Entering directory `/path/to/my/dir'
make
make[2]: Entering directory `/path/to/my/dir'
make
make[3]: Entering directory `/path/to/my/dir'
make
make[4]: Entering directory `/path/to/my/dir'
make
make[5]: Entering directory `/path/to/my/dir'
make
make[6]: Entering directory `/path/to/my/dir'
make
make[7]: Entering directory `/path/to/my/dir'
make
...

Alternate version, 5 bytes

Suggested by KonradRudolph:

x:;$_

$_ is a reference to the last argument of the previous command. More specifically, it is resolved here as the absolute path to the command being executed -- which is make itself.

This should work fine in a genuine Bash environment, but not on Windows+MinGW.

C++, 60 58

template<class T>class a{a<T*>operator->();};a<int>i=i->b;

This recursivly creates instances of class a with different template parameters. GCC 7.0 stops after 900 recursion levels with tons of errors about operator-> being private but for example ICC 17 and Microsoft (R) C/C++ Optimizing Compiler 19 time out on godbolt.

Problem with that is that probably all compilers will run out of memory at some point in time so even without recursion limits this will stop. The same probably applies to the Clojure answer, too.

Edit: 2 bytes saved by bolov - Thanks

Common Lisp, 8 bytes

#.(loop)

The compiler will try to read a form and will encounter the sharpsign-dot reader macro, which evaluates code at read time and uses its result as the form to compile. Here, the code being executed is an infinite loop.

C, 18 bytes

#include __FILE__

Compilers will usually give up after recursing about 200 times.

Does DOM construction count as a compilation step? If so, then x.htm:

<iframe src=x.htm>