Skip to main content
deleted 6 characters in body
Source Link
Colera Su
  • 2.4k
  • 14
  • 30

8582 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 - 53755381 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 if you deletewithout 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>({a}));}int main(){f(0);} 

Try it online!Try it online!

85 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 - 5375 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 if you delete 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>({a}));}int main(){f(0);} 

Try it online!

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);} 

Try it online!

added 116 characters in body
Source Link
Colera Su
  • 2.4k
  • 14
  • 30

85 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 - 5375 bytes of error messages (compiled by gcc 7.2.0). That is, in default settings (x=900), it will output about 44.9×10419 bytes of error message theoretically.9×10419 bytes of

Note that if you delete the return statement, the error message theoreticallymessages 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>({a}));}int main(){f(0);} 

Try it online!

85 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 - 5375 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.

Warning: Compiling this program will consume lots of memory.

#include<set> template<class T>T f(T a){return f(std::set<T>({a}));}int main(){f(0);} 

Try it online!

85 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 - 5375 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 if you delete 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>({a}));}int main(){f(0);} 

Try it online!

added 116 characters in body
Source Link
Colera Su
  • 2.4k
  • 14
  • 30

8785 bytes: This one works similar to Joey Adams' approach, but the error message will grow exponentially with respect to -ftemplate-depth (because std::list<T>set<T> is actually std::list<Tset<T, std::less<T>, std::allocator<T>>). In default settings

For ((x = -ftemplate-depth=900depth) >= 28, there will be 1460×3x-27 + 269x - 5375 bytes of error messages (compiled by gcc 7.2.0). That is, in default settings (x=900), it will output about 18 x 24.9×10900419 bytes of error message theoretically.

Warning: Compiling this program will consume lots of memory.

#include<list>#include<set> template<class T>T f(T a){return f(std::list<T>set<T>({a}));}int main(){f(0);} 

Try it online!Try it online!

87 bytes: This one works similar to Joey Adams' approach, but the error message will grow exponentially with respect to -ftemplate-depth (because std::list<T> is actually std::list<T, std::allocator<T>>). In default settings (-ftemplate-depth=900), it will output about 18 x 2900 bytes of error message theoretically.

Warning: Compiling this program will consume lots of memory.

#include<list> template<class T>T f(T a){return f(std::list<T>({a}));}int main(){f(0);} 

Try it online!

85 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 - 5375 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.

Warning: Compiling this program will consume lots of memory.

#include<set> template<class T>T f(T a){return f(std::set<T>({a}));}int main(){f(0);} 

Try it online!

Source Link
Colera Su
  • 2.4k
  • 14
  • 30
Loading