1. Лучший говнокод

    В номинации:
    За время:
  2. Куча / Говнокод #29245

    0

    1. 1
    Питушня #43

    #13: https://govnokod.ru/27260 https://govnokod.xyz/_27260
    #14: https://govnokod.ru/27343 https://govnokod.xyz/_27343
    #15: https://govnokod.ru/27353 https://govnokod.xyz/_27353
    #16: https://govnokod.ru/27384 https://govnokod.xyz/_27384
    #17: https://govnokod.ru/27482 https://govnokod.xyz/_27482
    #18: https://govnokod.ru/27514 https://govnokod.xyz/_27514
    #19: https://govnokod.ru/27620 https://govnokod.xyz/_27620
    #20: https://govnokod.ru/27816 https://govnokod.xyz/_27816
    #21: https://govnokod.ru/27956 https://govnokod.xyz/_27956
    #22: https://govnokod.ru/28143 https://govnokod.xyz/_28143
    #23: https://govnokod.ru/28315 https://govnokod.xyz/_28315
    #24: (vanished) https://govnokod.xyz/_28362
    #25: (vanished) https://govnokod.xyz/_28463
    #26: https://govnokod.ru/28481 https://govnokod.xyz/_28481
    #27: https://govnokod.ru/28537 https://govnokod.xyz/_28537
    #28: https://govnokod.ru/28619 https://govnokod.xyz/_28619
    #29: (vanished) https://govnokod.xyz/_28663
    #30: https://govnokod.ru/28673 https://govnokod.xyz/_28673
    #31: https://govnokod.ru/28679 https://govnokod.xyz/_28679
    #32: https://govnokod.ru/28687 https://govnokod.xyz/_28687
    #33: https://govnokod.ru/28694 https://govnokod.xyz/_28694
    #34: https://govnokod.ru/28701 https://govnokod.xyz/_28701
    #35: https://govnokod.ru/28707 https://govnokod.xyz/_28707
    #36: https://govnokod.ru/28714 https://govnokod.xyz/_28714
    #37: https://govnokod.ru/28724 https://govnokod.xyz/_28724
    #38: https://govnokod.ru/28732 https://govnokod.xyz/_28732
    #39: https://govnokod.ru/28839 https://govnokod.xyz/_28839
    #40: https://govnokod.ru/28909 https://govnokod.xyz/_28909
    #41: https://govnokod.ru/29003 https://govnokod.xyz/_29003
    #42: https://govnokod.ru/29186 https://govnokod.xyz/_29186

    nepeKamHblu_nemyx, 31 Марта 2026

    Комментарии (180)
  3. C++ / Говнокод #27312

    +1

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    21. 21
    22. 22
    23. 23
    24. 24
    25. 25
    26. 26
    27. 27
    28. 28
    29. 29
    30. 30
    31. 31
    32. 32
    33. 33
    34. 34
    35. 35
    36. 36
    37. 37
    38. 38
    39. 39
    #include <iostream>
    
    template<typename T>
    struct CrtpBase {
        static float base_func()
        {
            std::cout << "CrtpBase::base_func(), " << typeid(T).name() << "::int_field == "
                << T::int_field << std::endl;
            return 16.0f;
        }
    
        static inline float x = base_func();
    };
    
    struct A: public CrtpBase<A> {
        void func_a()
        {
            base_func();
        }
    
        static inline int int_field = 16;
    };
    
    struct B : public CrtpBase<B> {
        void func_b()
        {
            std::cout << "B::func_b(), no CrtpBase<B>::base_func() call" << std::endl;
        }
    };
    
    
    int main()
    {
        A a;
        a.func_a();
    
        B b;
        b.func_b();
    }

    [temp.inst]/2:
    Unless a class template specialization is a declared specialization,
    the class template specialization is implicitly instantiated when
    the specialization is referenced in a context that requires a
    completely-defined object type or when the completeness of the
    class type affects the semantics of the program.

    [temp.inst]/3:
    The implicit instantiation of a class template specialization causes
    (3.1) -- the implicit instantiation of the declarations, but not of the definitions, of
    the non-deleted class member functions, member classes, scoped member enumerations,
    static data members, member templates, and friends; and
    (3.2) -- the implicit instantiation of the definitions of deleted member functions,
    unscoped member enumerations, and member anonymous unions.

    [temp.inst]/4:
    Unless a member of a templated class is a declared specialization, the specialization
    of the member is implicitly instantiated when the specialization is referenced in a
    context that requires the member definition to exist or if the existence of the definition
    of the member affects the semantics of the program; in particular, the initialization
    (and any associated side effects) of a static data member does not occur unless the
    static data member is itself used in a way that requires the definition of the static
    data member to exist.


    Таким образом, по стандарту CrtpBase<B>::x не должен быть инициализирован, поскольку он нигде не used in a way that requires the definition of the static data member to exist. Правильные компиляторы (gcc и clang) это понимают и компилируют код, а вот Visual Studio зачем-то пытается инициализировать CrtpBase<B>::x и нон-конформно ломается.

    PolinaAksenova, 24 Марта 2021

    Комментарии (179)
  4. Си / Говнокод #26034

    +2

    1. 1
    2. 2
    Comparing structs with, let's say, memcmp, does not work,
     as you end up comparing the "unspecified" padding bytes as well — you must compare member-by-member.

    While writing this post, the author observed that some verions of GCC (experimentally, >= 4.7, < 8.0) do not zero padding if an empty intializer list is passed, under certain a certain code pattern; if an entire struct (i.e. sizeof(STRUCTNAME)) is subsequently memcpy'd after assigment of its members, and this intermediate buffer is what is used by the code going forward. This appears to be based on how optimization passes interact with GCC's built-in memcpy, since passing -fno-builtin-memcpy returns the behavior to the expected.
    https://www.nccgroup.trust/us/about-us/newsroom-and-events/blog/2019/october/padding-the-struct-how-a-compiler-optimization-can-disclose-stack-memory/

    3.14159265, 18 Ноября 2019

    Комментарии (179)
  5. PHP / Говнокод #19018

    +13

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    21. 21
    22. 22
    23. 23
    24. 24
    25. 25
    26. 26
    27. 27
    28. 28
    <?php
      $lines = file('quest.txt');
      if($_POST['Quest'] == "") {
        echo "<HTML>";
        echo "<HEAD>";
        echo "<TITLE>Тестер</TITLE>";
        echo "<script language=JavaScript type=text/javascript>";
        echo "<!-- " . "\n";
        echo "var differ = 90*60;";
        echo "function timer() {";
        echo "var hours, minutes, seconds;";
        echo "differ = differ - 1;";
        echo "document.forms['vopros'].TimeLeft.value=differ;";
        echo "hours = Math.floor(differ/(60*60));";
        echo "hours = (hours >= 60) ? hours%60 : hours;";
        echo "hours = (hours < 10) ? \"0\" + hours : hours;";
        echo "minutes = Math.floor(differ/(60));";
        echo "minutes = (minutes >= 60) ? minutes%60 : minutes;";
        echo "minutes = (minutes < 10) ? \"0\" + minutes : minutes;";
        echo "seconds = differ;";
        echo "seconds = (seconds >= 60) ? seconds%60 : seconds;";
        echo "seconds = (seconds < 10) ? \"0\" + seconds : seconds;";
        echo "var strDate =  hours + \":\" + minutes + \":\" + seconds;";
        echo "document.forms['timerForm'].timerBox.value=strDate;";
        echo "if (differ<=0) {";
        echo "  document.forms['vopros'].Quest.value=100;";
        echo "  vopros.submit();";
    ... (и так далее)

    Отличный кодец из дипломной работы студента!

    RigFox, 13 Ноября 2015

    Комментарии (179)
  6. Куча / Говнокод #14293

    +113

    1. 1
    2. 2
    Стартовал форум работы еще много,  тестить уже можно 
    http://gvforum.ru/

    Vasiliy, 28 Декабря 2013

    Комментарии (179)
  7. Куча / Говнокод #25108

    0

    1. 1
    Type: Null

    https://bulbapedia.bulbagarden.net/wiki/Type:_Null_(Pok%C3%A9mon)

    vistefan, 23 Ноября 2018

    Комментарии (178)
  8. C++ / Говнокод #13201

    +21

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    21. 21
    22. 22
    23. 23
    24. 24
    25. 25
    26. 26
    class socket_exception                                                                                                                        
    {                                                                                                                                              
    public:                                                                                                                                    
                char *buf;                                                                                                                             
                int ret;                                                                                                                               
                socket_exception()                                                                                                                    
                {                                                                                                                                      
                    buf=new char[10000];                                                                                                               
                    ret=RET_OK;                                                                                                                        
                }                                                                                                                                      
                socket_exception(char *b, int r)                                                                                                      
                {                                                                                                                                      
                    buf=new char[10000];                                                                                                               
                    snprintf(buf,9999,"%s",b);                                                                                                         
                    ret=r;                                                                                                                             
                }                                                                                                                                      
                socket_exception(vsocket_exception &ex)                                                                                               
                {                                                                                                                                      
                    buf=new char[10000];                                                                                                               
                    snprintf(buf, 9999, "%s", ex.buf);                                                                                                 
                    ret=ex.ret;                                                                                                                        
                }                                                                                                                                      
                const char * what (){return buf;}                                                                                                      
                int get_ret(){return ret;}                                                                                                             
                ~socket_exception(){delete[] buf;}                                                                                                    
    };

    фрактал

    roman-kashitsyn, 20 Июня 2013

    Комментарии (178)
  9. Pascal / Говнокод #8664

    +102

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    function naq(a:integer;n:integer;m:integer):string;
    var astr:string;
    begin
      astr:=inttostr(a);
         case m of
           1: naq:=astr+'*p^'+inttostr(n)+'-'+inttostr(a*1)+'*p^'+inttostr(n+1);
           2: naq:=astr+'*p^'+inttostr(n)+'-'+inttostr(a*2)+'*p^'+inttostr(n+1)+'+'+inttostr(a*1)+'*p^'+inttostr(n+2);
           3: naq:=astr+'*p^'+inttostr(n)+'-'+inttostr(a*3)+'*p^'+inttostr(n+1)+'+'+inttostr(a*3)+'*p^'+inttostr(n+2)+'-'+inttostr(a*1)+'*p^'+inttostr(n+3);
           4: naq:=astr+'*p^'+inttostr(n)+'-'+inttostr(a*4)+'*p^'+inttostr(n+1)+'+'+inttostr(a*6)+'*p^'+inttostr(n+2)+'-'+inttostr(a*4)+'*p^'+inttostr(n+3)+'+'+inttostr(a*1)+'*p^'+inttostr(n+4);
           5: naq:=astr+'*p^'+inttostr(n)+'-'+inttostr(a*5)+'*p^'+inttostr(n+1)+'+'+inttostr(a*10)+'*p^'+inttostr(n+2)+'-'+inttostr(a*10)+'*p^'+inttostr(n+3)+'+'+inttostr(a*5)+'*p^'+inttostr(n+4)+'-'+inttostr(a*1)+'*p^'+inttostr(n+5);
           6: naq:=astr+'*p^'+inttostr(n)+'-'+inttostr(a*6)+'*p^'+inttostr(n+1)+'+'+inttostr(a*15)+'*p^'+inttostr(n+2)+'-'+inttostr(a*20)+'*p^'+inttostr(n+3)+'+'+inttostr(a*15)+'*p^'+inttostr(n+4)+'-'+inttostr(a*6)+'*p^'+inttostr(n+5)+'+'+inttostr(a*1)+'*p^'+inttostr(n+6);
           7: naq:=astr+'*p^'+inttostr(n)+'-'+inttostr(a*7)+'*p^'+inttostr(n+1)+'+'+inttostr(a*21)+'*p^'+inttostr(n+2)+'-'+inttostr(a*35)+'*p^'+inttostr(n+3)+'+'+inttostr(a*35)+'*p^'+inttostr(n+4)+'-'+inttostr(a*21)+'*p^'+inttostr(n+5)+'+'+inttostr(a*7)+'*p^'+inttostr(n+6)+'-'+inttostr(a*1)+'*p^'+inttostr(n+7);
           8: naq:=astr+'*p^'+inttostr(n)+'-'+inttostr(a*8)+'*p^'+inttostr(n+1)+'+'+inttostr(a*28)+'*p^'+inttostr(n+2)+'-'+inttostr(a*56)+'*p^'+inttostr(n+3)+'+'+inttostr(a*70)+'*p^'+inttostr(n+4)+'-'+inttostr(a*56)+'*p^'+inttostr(n+5)+'+'+inttostr(a*28)+'*p^'+inttostr(n+6)+'-'+inttostr(a*8)+'*p^'+inttostr(n+7)+'+'+inttostr(a*1)+'*p^'+inttostr(n+8);
           9: naq:=astr+'*p^'+inttostr(n)+'-'+inttostr(a*9)+'*p^'+inttostr(n+1)+'+'+inttostr(a*36)+'*p^'+inttostr(n+2)+'-'+inttostr(a*84)+'*p^'+inttostr(n+3)+'+'+inttostr(a*126)+'*p^'+inttostr(n+4)+'-'+inttostr(a*126)+'*p^'+inttostr(n+5)+'+'+inttostr(a*84)+'*p^'+inttostr(n+6)+'-'+inttostr(a*36)+'*p^'+inttostr(n+7)+'+'+inttostr(a*9)+'*p^'+inttostr(n+8)+'+'+inttostr(a*1)+'*p^'+inttostr(n+9);
         end;
      end;

    Лень было искать алгоритм раскрытия (1-q)^n

    rob1nzon, 28 Ноября 2011

    Комментарии (178)
  10. PHP / Говнокод #8115

    +160

    1. 1
    2. 2
    3. 3
    4. 4
    $url = $_SERVER['HTTP_REFERER'];	
    	
    $pos = strrpos($url, 'id');
    $id = substr($url, $pos + 2);

    Получаем id человека)))

    OJA, 08 Октября 2011

    Комментарии (178)
  11. C# / Говнокод #26533

    +1

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    21. 21
    22. 22
    23. 23
    24. 24
    25. 25
    26. 26
    27. 27
    28. 28
    29. 29
    30. 30
    31. 31
    32. 32
    33. 33
    34. 34
    35. 35
    36. 36
    37. 37
    38. 38
    39. 39
    40. 40
    41. 41
    42. 42
    43. 43
    using System;
     
    namespace Test
    {
        public class HttpException : Exception
        {
            public HttpException(int status)
            {
                StatusCode = status;
            }
     
            public int StatusCode { get; set; }
        }
     
        class Program
        {
            static void TestCatch(int status)
            {
                try
                {
                    throw new HttpException(status);
                }
                catch (HttpException ex) when (ex.StatusCode == 404)
                {
                    Console.WriteLine("Not Found!");
                }
                catch (HttpException ex) when (ex.StatusCode >= 500 && ex.StatusCode < 600)
                {
                    Console.WriteLine("Server Error");
                }
                catch (HttpException ex)
                {
                    Console.WriteLine("HTTP Error {0}", ex.StatusCode);
                } 
            }
            static void Main(string[] args)
            {
                TestCatch(404);
                TestCatch(501);
                TestCatch(101);
            }
        }
    }

    https://ideone.com/zXstg3
    Именно поэтому я за «C#».

    gost, 27 Марта 2020

    Комментарии (177)