-
+5
- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
#include <iostream>
using namespace std;
void f(void){cout<<"f"<<endl;}
void f1(void){cout<<"f1"<<endl;}
bool secondIfIsTryed(){cout<<"secondIfIsTryed"<<endl;return true;}
#define asserts(Condition) {cout<<"Assert"<<endl;}
int main() {
if(true)
if(secondIfIsTryed() && false)
f();
else
f1();
if(true)
if(secondIfIsTryed() && false)
asserts(true)
else
f1();
return 0;
}
Помните того вечно сомневающегося знакомого, тест крестов, написанный которым я недавно приводил?
http://ideone.com/9Q61D1
В этот раз под его глуповатый, но пытливый взгляд попал макрос ассерта. Написан он конечно не так, как в этом тесте, но имеет код вида:
#define asserts(Condition) {/*...*/}
В итоге он сделал умозаключение: "Вокруг меня собрались голубцы" и надулся.
LispGovno,
19 Июля 2013
-
+124
- 1
- 2
- 3
// Просрока быть недолжно.
// Если нет платежа, то будет исключение.
// Оба эти случая логически исключены, если медот не дергать в неположеном месте.
dimkich,
19 Июля 2013
-
+124
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
class Comparer : IComparer<int>
{
Random random = new Random();
public int Compare(int x, int y)
{
return 1 - random.Next() % 3;
}
}
Ccik,
18 Июля 2013
-
−165
- 1
if ( $method{'out_format'} && $method{'out_format'} eq lc(q{json}) ) {
Yo dawg, we heard that you like lowercase, so we put some lowercase into your lowercase
Elvenfighter,
18 Июля 2013
-
+149
- 1
if('null'==$this->user_data['e_mail']) $this->user_data['e_mail']=null;
clgs,
18 Июля 2013
-
+148
- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
Class FactoryAchievesController {
public static function factory($type)
{
try {
if ($type) {
$classname = ucfirst(strtolower($type)).'AchievesController';
if (require_once 'class.achieves.'.$type . '.php') {
return new $classname;
} else {
throw new Exception('Class '.$classname.' not found');
}
} else {
throw new Exception('Achieves type not defined');
}
} catch (Exception $exc) {
// LOG
//echo $exc->getTraceAsString();
}
}
}
Свой классный автолоад с фаталами
dimkich,
18 Июля 2013
-
+3
- 1
typedef std::vector/*deque recommended*/<index_history_item> index_history;
Как понимать этот комментарий?
HaskellGovno,
18 Июля 2013
-
+148
- 1
- 2
- 3
- 4
- 5
- 6
$type = isset($config['type']) ? $config['type'] : 'default';
switch($type) {
default:
$blockClass = 'adminhtml/widget_grid_massaction_item_additional_default';
break;
}
Magento core
crook,
18 Июля 2013
-
+88
- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
program Project6;
{$APPTYPE CONSOLE}
uses SysUtils;
type TIntArr = array of integer;
function GetSingleArr (i: integer): TIntArr;
begin
SetLength(Result, 1);
Result[0] := i;
end;
var
W: TIntArr;
i : integer;
begin
readln(i);
if i=0 then begin
W := GetSingleArr(5);
WriteLn(W[0]);
end;
ReadLn;
end.
Delphi-7
[Warning] Project6.dpr(25): Variable 'W' might not have been initialized
Да какого хуя? Динмассив вообще по определению - чисто автоматический тип, как он может не инициализироваться?
И почему для других типов такая хрень не вылазит?
TarasB,
18 Июля 2013
-
+138
- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
uint32_t multiply (uint16_t a, uint16_t b)
{
return ((a & ( (int16_t)( ( b & (1 << 0) ) << 15 ) ) / ( 1 << 15) ) << 0 ) +
((a & ( (int16_t)( ( b & (1 << 1) ) << 14 ) ) / ( 1 << 15) ) << 1 ) +
((a & ( (int16_t)( ( b & (1 << 2) ) << 13 ) ) / ( 1 << 15) ) << 2 ) +
((a & ( (int16_t)( ( b & (1 << 3) ) << 12 ) ) / ( 1 << 15) ) << 3 ) +
((a & ( (int16_t)( ( b & (1 << 4) ) << 11 ) ) / ( 1 << 15) ) << 4 ) +
((a & ( (int16_t)( ( b & (1 << 5) ) << 10 ) ) / ( 1 << 15) ) << 5 ) +
((a & ( (int16_t)( ( b & (1 << 6) ) << 9 ) ) / ( 1 << 15) ) << 6 ) +
((a & ( (int16_t)( ( b & (1 << 7) ) << 8 ) ) / ( 1 << 15) ) << 7 ) +
((a & ( (int16_t)( ( b & (1 << 8) ) << 7 ) ) / ( 1 << 15) ) << 8 ) +
((a & ( (int16_t)( ( b & (1 << 9) ) << 6 ) ) / ( 1 << 15) ) << 9 ) +
((a & ( (int16_t)( ( b & (1 <<10) ) << 5 ) ) / ( 1 << 15) ) << 10) +
((a & ( (int16_t)( ( b & (1 <<11) ) << 4 ) ) / ( 1 << 15) ) << 11) +
((a & ( (int16_t)( ( b & (1 <<12) ) << 3 ) ) / ( 1 << 15) ) << 12) +
((a & ( (int16_t)( ( b & (1 <<13) ) << 2 ) ) / ( 1 << 15) ) << 13) +
((a & ( (int16_t)( ( b & (1 <<14) ) << 1 ) ) / ( 1 << 15) ) << 14) +
((a & ( (int16_t)( ( b & (1 <<15) ) << 0 ) ) / ( 1 << 15) ) << 15);
}
Умножение двух чисел через битовые маски и сдвиги без условных переходов. Компилятор переведет деление инта на сдвинутую единчку в арифметический сдвиг
Использование ">>" применительно к signed типам - implementation defined http://stackoverflow.com/questions/4009885/arithmetic-bit-shift-on-a-signed-integer/4009922
j123123,
18 Июля 2013