Quantcast
Channel: Generate the longest error message in C++ - Code Golf Stack Exchange
Browsing all 23 articles
Browse latest View live

Answer by Min Chan for Generate the longest error message in C++

1031892 bytes / 9 bytes = ratio 114654.666667Compiler g++-11, with -std=c++20 flagp<p<p<p<pproduces 1031892 bytes, or 21056 lines of error.first 20 lines look like this:test.cpp:1:9: error:...

View Article



Answer by burrito1 for Generate the longest error message in C++

(22009 characters) This is something a beginner might actually run into:Ungolfed:#include <array>#include <iostream>int main() { std::cout << std::array{1, 2, 3};}Golfed:#include...

View Article

Image may be NSFW.
Clik here to view.

Answer by eeeeeeeeeee for Generate the longest error message in C++

19 bytes... you need to get at least a few megabytes of errors (if you have bash under /bin/bash, untested with env)#include</bin/bash>under Windows 7 (/w Cygwin) in results i got 762140 lines of...

View Article

Answer by user101622 for Generate the longest error message in C++

with -std=c++20 flag:a<b<c<d<e<f<g

View Article

Answer by user541686 for Generate the longest error message in C++

This produces 21KB of output for me with GCC 10.1.0:#include <iostream>int main() { std::cin >> ""; }Output:error.cpp: In function ‘int main()’:error.cpp:2:23: error: no match for...

View Article


Answer by Zachary Vander Klippe for Generate the longest error message in C++

Forgetting a semi-colon before an include statementint i#include <stdio.h>I made this error in a header file which I had included in throughout most of my project before the standard libraries....

View Article

Answer by elipszilon for Generate the longest error message in C++

A file named a.cpp. Code:main(){#include "a.cpp"#include "a.cpp"#include "a.cpp"#include "a.cpp"#include "a.cpp"#include "a.cpp"#include "a.cpp"#include "a.cpp"#include "a.cpp"#include "a.cpp"#include...

View Article

Answer by Colera Su for Generate the longest error message in C++

82 bytes: This one works similar to Joey Adams' approach, but the error message will grow exponentially with respect to -ftemplate-depth (because std::set<T> is actually std::set<T,...

View Article


Answer by Jean-Michaël Celerier for Generate the longest error message in C++

50 bytes: Result will be the sum of the length of all the positive numbers with a single error message:#include<utility>std::make_index_sequence<-1>::x;174 bytes: quadratic explosion with...

View Article


Answer by Alexander Shishenko for Generate the longest error message in C++

This produces infinite output on GCC 5.2 and Clang 3.6 (on Clang requires -ferror-limit=0, on GCC works with default settings):#include __FILE__#include __FILE__

View Article

Answer by Tim for Generate the longest error message in C++

C++Based on BЈовић's solution:File: golf.cpp:#include "golf.cpp"#include "golf.cpp"Running this under G++ will not finish, however, I have computed the length of the error it will eventually emit as...

View Article

Answer by nneonneo for Generate the longest error message in C++

28 bytesSabotaging the standard library:#define std +#include<map>Using clang on OS X 10.9:c++ foo.cpp -o foo -ferror-limit=-1In file included from foo.cpp:2:In file included from...

View Article

Answer by ApproachingDarknessFish for Generate the longest error message in C++

The following code is based on an actual error I once encountered.template <int i>void bar();template <int i>void foo(){ bar<i>(); char baz[i];}template <int i>void bar(){...

View Article


Answer by jb. for Generate the longest error message in C++

I stumbled across this by accident: #include<functional>#include<algorithm>#include<array>#include<stdexcept>int main(int argc,char** argv){ std::array<double, 3> arr;...

View Article

Answer by Manu343726 for Generate the longest error message in C++

C++11 variadic templates (69 characters)template<int... p>void f(){ return f<0,p...>();}int main() { f();}Configuring maximum template instantation depth you could set the length of the...

View Article


Answer by kebs for Generate the longest error message in C++

Template error messages are fun to decipher. Consider this:#include <vector>#include <algorithm>int main(){ int a; std::vector< std::vector <int> > v; std::vector<...

View Article

Answer by cozzyd for Generate the longest error message in C++

Similar to VJo:a.cpp:int main() { return #include "a.cpp"#include "a.cpp"}g++ a.cppproduces a lot of output (at least 2 gigabytes before I killed it)

View Article


Answer by seriousdev for Generate the longest error message in C++

Based on a message length / code length ratio, this may be the best solution:Message (81):code: file not recognized: File truncated collect2: ld returned 1 exit status 81 / 0 = Inf

View Article

Answer by BЈовић for Generate the longest error message in C++

19 charactersCreate a file a.cpp with this content : #include __FILE__p;Compile as : g++ a.cppand get amazing 21300 lines error messages : In file included from a.cpp:1:0, from a.cpp:1, from a.cpp:1,...

View Article

Answer by Keith Randall for Generate the longest error message in C++

279 chars#define A(s) s##s##s##s##s##s##s##s#define B(s) A(s##s##s##s##s##s##s##s)#define C(s) B(s##s##s##s##s##s##s##s)#define D(s) C(s##s##s##s##s##s##s##s)#define E(s)...

View Article
Browsing all 23 articles
Browse latest View live




Latest Images