1. C++ / Говнокод #17567

    +48

    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
    void Sender::exceptionHandler()
    {
    	try
    	{
    		throw;
    	}
    	catch (std::exception& ex)
    	{
    		Log::write(ex);
    	}
    	catch (...)
    	{
    		Log::write("I am CraZzY!");

    laMer007, 03 Февраля 2015

    Комментарии (4)
  2. C++ / Говнокод #17558

    +53

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    for (int i = 1; i <= s.Length; ++i) {
        if (s[i] == '/') {
            s = s.SubString(1, i) + s.SubString(i, MaxInt);
            ++i;
        }
    }

    Кручу-верчу запутать хочу. Кто с первого раза догадается, в чём задача кода - получит пирожок с полочки.

    P.S. Строки билдеровские, нумерация с 1. SubString принимает индекс начала и количество символов.

    bormand, 02 Февраля 2015

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

    +65

    1. 1
    2. 2
    3. 3
    4. 4
    std::string Operations::getLastError()
    	{
    		return "Произошла неизвестная ошибка при выполнении криптооперации";
    	}

    laMer007, 30 Января 2015

    Комментарии (25)
  4. C++ / Говнокод #17541

    +67

    1. 1
    2. 2
    3. 3
    4. 4
    catch (...) 
    	{
    		return -__LINE__;
    	}

    laMer007, 29 Января 2015

    Комментарии (25)
  5. C++ / Говнокод #17537

    +143

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    int n;
        cin >> n;
        int nums[n];
        for (int i = 0; i < n; i++)
            nums[i] = pow(i + 1, 2);

    Немного эзотерики.
    nums[4] = 24

    DesmondHume, 28 Января 2015

    Комментарии (147)
  6. C++ / Говнокод #17530

    +51

    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
    static bool convertCharToHexByte(char& ch)
    {
    	if (ch >= '0' && ch <= '9') {
    		ch -= '0';
    		return true;
    	}
    
    	if (ch >= 'a' && ch <= 'f') {
    		ch -= 'a';
    		ch += 0xA;
    		return true;
    	}
    
    	if (ch >= 'A' && ch <= 'F') {
    		ch -= 'A';
    		ch += 0xA;
    		return true;
    	}
    
    	return false;
    }

    alek0585, 27 Января 2015

    Комментарии (29)
  7. C++ / Говнокод #17527

    +54

    1. 1
    2. 2
    _defaultLog
    #include "stdafx.h"

    Это первые две строчки в C++ файле. Сам файл включен файл проекта. Ошибок компиляции нет. Сегодня удалю эту первую строку. В комментариях к комиту с этим изменением в свн написано: "Исправление дидлока".

    laMer007, 27 Января 2015

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

    +141

    1. 1
    strcat(strcpy(malloc(strlen(argv[0]) + sizeof(".track")), argv[0]), ".track")

    LispGovno, 24 Января 2015

    Комментарии (94)
  9. C++ / Говнокод #17506

    +50

    1. 1
    2. 2
    3. 3
    if ( !log.append(log_line) )
    
    log.append("Can't append to log");

    laMer007, 23 Января 2015

    Комментарии (13)
  10. C++ / Говнокод #17505

    +54

    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
    // We now have a locale string, but the global locale can be changed by
    // another thread. If we allow this thread's locale to be updated before we're done
    // with this string, it might be freed from under us.
    // Call versions of the wide-to-MB-char conversions that do not update the current thread's
    // locale.
    
    //...
    
    /*
                 * Note that we are using a risky trick here.  We are adding this
                 * locale to an existing threadlocinfo struct, and thus starting
                 * the locale's refcount with the same value as the whole struct.
                 * That means all code which modifies both threadlocinfo::refcount
                 * and threadlocinfo::lc_category[]::refcount in structs that are
                 * potentially shared across threads must make those modifications
                 * under _SETLOCALE_LOCK.  Otherwise, there's a race condition
                 * for some other thread modifying threadlocinfo::refcount after
                 * we load it but before we store it to refcount.
                 */

    MS VS 2013 CRT

    LispGovno, 23 Января 2015

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