Follow-up Comment #3, bug #19029 (project freeciv): Interesting observation: I was testing the fix for bug #19007 with a player with index 125, and it didn't occur to me until later that this bug (#19029) should have been biting me, and wasn't.
It turns out that on my platform at least (Linux x86_64), attempting to shift 1u left by x where x>32 appears to give the result of shifting by (x%32). As a result, I don't think this bug bites at all on my platform, _provided that_ I save and load on the same platform -- all the bits are there, just in a funny order. It means we've now got platform-dependent savefiles, though, and there probably is some platform where it does discard data. The obvious backwards compatibility plan is to keep the loading code with the platform-dependent behaviour, and we'll have to keep it more or less forever, which will probably cause some compiler to shout at us at some point. Ugh. The attached small C program shows the pattern of bits I get. This is similar to what akfaew posted in bug #18776 comment 24 <http://gna.org/bugs/?18776#comment24>, but he didn't post his results (which are presumably on Sparc OpenBSD). Here are mine: 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 (It shows the results of shifting both a signed and unsigned int. That's another thing that's dodgy about this code -- mixing signed ints and bitwise operators.) (file #14590) _______________________________________________________ Additional Item Attachment: File name: test-19029.c Size:0 KB _______________________________________________________ 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