Follow-up Comment #4, bug #19029 (project freeciv):

>From n1256:

6.5.7 Bitwise shift operators
Syntax
        shift-expression:
                additive-expression
                shift-expression << additive-expression
                shift-expression >> additive-expression
Constraints
Each of the operands shall have integer type.
Semantics
The integer promotions are performed on each of the operands. The type of the
result is
that of the promoted left operand. If the value of the right operand is
negative or is
greater than or equal to the width of the promoted left operand, the behavior
is undefined.

So we have undefined behaviour.

sparc64 output of your program:

  0:               1,               1
  1:               2,               2
  2:               4,               4
  3:               8,               8
  4:              16,              16
  5:              32,              32
  6:              64,              64
  7:             128,             128
  8:             256,             256
  9:             512,             512
 10:            1024,            1024
 11:            2048,            2048
 12:            4096,            4096
 13:            8192,            8192
 14:           16384,           16384
 15:           32768,           32768
 16:           65536,           65536
 17:          131072,          131072
 18:          262144,          262144
 19:          524288,          524288
 20:         1048576,         1048576
 21:         2097152,         2097152
 22:         4194304,         4194304
 23:         8388608,         8388608
 24:        16777216,        16777216
 25:        33554432,        33554432
 26:        67108864,        67108864
 27:       134217728,       134217728
 28:       268435456,       268435456
 29:       536870912,       536870912
 30:      1073741824,      1073741824
 31:     -2147483648,      2147483648
 32:        16777216,        16777216
 33:        33554432,        33554432
 34:        67108864,        67108864
 35:       134217728,       134217728
 36:       268435456,       268435456
 37:       536870912,       536870912
 38:      1073741824,      1073741824
 39:     -2147483648,      2147483648
 40:               1,               1
 41:               2,               2
 42:               4,               4
 43:               8,               8
 44:              16,              16
 45:              32,              32
 46:              64,              64
 47:             128,             128
 48:             256,             256
 49:             512,             512
 50:            1024,            1024
 51:            2048,            2048
 52:            4096,            4096
 53:            8192,            8192
 54:           16384,           16384
 55:           32768,           32768
 56:           65536,           65536
 57:          131072,          131072
 58:          262144,          262144
 59:          524288,          524288
 60:         1048576,         1048576
 61:         2097152,         2097152
 62:         4194304,         4194304
 63:         8388608,         8388608
 64:           65536,           65536
 65:          131072,          131072
 66:          262144,          262144
 67:          524288,          524288
 68:         1048576,         1048576
 69:         2097152,         2097152
 70:         4194304,         4194304
 71:         8388608,         8388608
 72:        16777216,        16777216
 73:        33554432,        33554432
 74:        67108864,        67108864
 75:       134217728,       134217728
 76:       268435456,       268435456
 77:       536870912,       536870912
 78:      1073741824,      1073741824
 79:     -2147483648,      2147483648
 80:               1,               1
 81:               2,               2
 82:               4,               4
 83:               8,               8
 84:              16,              16
 85:              32,              32
 86:              64,              64
 87:             128,             128
 88:             256,             256
 89:             512,             512
 90:            1024,            1024
 91:            2048,            2048
 92:            4096,            4096
 93:            8192,            8192
 94:           16384,           16384
 95:           32768,           32768
 96:             256,             256
 97:             512,             512
 98:            1024,            1024
 99:            2048,            2048
100:            4096,            4096
101:            8192,            8192
102:           16384,           16384
103:           32768,           32768
104:           65536,           65536
105:          131072,          131072
106:          262144,          262144
107:          524288,          524288
108:         1048576,         1048576
109:         2097152,         2097152
110:         4194304,         4194304
111:         8388608,         8388608
112:        16777216,        16777216
113:        33554432,        33554432
114:        67108864,        67108864
115:       134217728,       134217728
116:       268435456,       268435456
117:       536870912,       536870912
118:      1073741824,      1073741824
119:     -2147483648,      2147483648
120:               1,               1
121:               2,               2
122:               4,               4
123:               8,               8
124:              16,              16
125:              32,              32

Seems identical

    _______________________________________________________

Reply to this item at:

  <http://gna.org/bugs/?19029>

_______________________________________________
  Message sent via/by Gna!
  http://gna.org/


_______________________________________________
Freeciv-dev mailing list
Freeciv-dev@gna.org
https://mail.gna.org/listinfo/freeciv-dev

Reply via email to