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, std::less<T>, std::allocator<T>>
).
For (x = -ftemplate-depth) >= 28
, there will be 1460×3x-27+ 269x - 5381 bytes of error messages (compiled by gcc 7.2.0). That is, in default settings (x=900), it will output about 4.9×10419 bytes of error message theoretically.
Note that without the return
statement, the error messages will only produced at the end of the compiling. (so in default settings you won't get the messages - you will run out of memory first.)
Warning: Compiling this program will consume lots of memory.
#include<set>template<class T>T f(T a){return f(std::set<T>());}int main(){f(0);}