Skip to main content
3 of 7
added 137 characters in body
Mark Lakata
  • 1.6k
  • 12
  • 13

1 character typo generating most error messages from C++ compilation

It seems that simple changes to a C++ file, especially with templates, can generate pages of errors. This contest is to see what the largest "bang of the buck" is, that is the more verbose error output with the smallest change to the source code (1 character addition).

Because other languages are more sane, this will be limited to C++ and gcc version 4.x.

Rules

  1. Original source file must compile with gcc 4.9.2 to object code without error.

  2. One ASCII character is added to source code to create a typo, increasing file size by 1 byte.

  3. Compiler is run with default options. Necessary options like -c and -std=c++11 are allowed, options like -Wall are not.

  4. Metric is

        number of bytes of generated error messages
        -----------------------------------------------------------------------
        (bytes of source code with typo) (length of filename passed to compiler)
    
  5. Answers will be validated with http://ideone.com/ C++ 4.9.2.

Example:

Filename is a.cpp, which is 5 bytes long.

int foo();

Working Compilation

 gcc -c a.cpp

Corrupted source code:

in t foo();

Failing Compilation

$ gcc -c a.cpp
a.cpp:1:1: error: ‘in’ does not name a type
in t foo();
  ^
$ gcc -c a.cpp |& -c wc
64
$ wc -c a.cpp
12 a.cpp

Score: 64/12/5 = 1.0666

Better attempt: Insert { between parens of foo()

$ gcc -c a.cpp |& wc -c
497

New score: 497/12/5 = 8.283

Good Luck!

UPDATE

I encourage people to ignore the recursive implementation. That technically wins but is not in the spirit of the contest.

Mark Lakata
  • 1.6k
  • 12
  • 13