char
is signed or unsigned on each compiler. That could cause a lot of trouble. Another possibility is that your memory management is off. This could cause different behavior on different OSs, or even when slightly changing the code.
|
|
ret_a_power()
and ret_integer()
?
|
|
|
|
VS :: S0=0 S1=0 S2=0 S3=0 GCC :: S0=0 S1=1 S2=58 S3=140 |
S[i] ^= hold;
S[i] = hold;
Before : S[0] = 0 rx[0] = 16 After : S[0] = 16 rx[0] = 16 Before : S[0] = 16 rx[1] = 140 After : S[0] = 156 rx[1] = 140 Before : S[0] = 156 rx[2] = 12 After : S[0] = 144 rx[2] = 12 Before : S[0] = 144 rx[3] = 86 After : S[0] = 198 rx[3] = 86 Before : S[0] = 198 rx[4] = 106 After : S[0] = 172 rx[4] = 106 Before : S[0] = 172 rx[5] = 110 After : S[0] = 194 rx[5] = 110 Before : S[0] = 194 rx[6] = 20 After : S[0] = 214 rx[6] = 20 Before : S[0] = 214 rx[7] = 234 After : S[0] = 60 rx[7] = 234 Before : S[0] = 60 rx[8] = 141 After : S[0] = 177 rx[8] = 141 Before : S[0] = 177 rx[9] = 247 After : S[0] = 70 rx[9] = 247 Before : S[0] = 70 rx[10] = 161 After : S[0] = 231 rx[10] = 161 Before : S[0] = 231 rx[11] = 237 After : S[0] = 10 rx[11] = 237 Before : S[0] = 10 rx[12] = 200 After : S[0] = 194 rx[12] = 200 Before : S[0] = 194 rx[13] = 197 After : S[0] = 7 rx[13] = 197 Before : S[0] = 7 rx[14] = 64 After : S[0] = 71 rx[14] = 64 Before : S[0] = 71 rx[15] = 196 After : S[0] = 131 rx[15] = 196 Before : S[0] = 131 rx[16] = 131 After : S[0] = 0 rx[16] = 0 Before : S[0] = 0 rx[17] = 0 After : S[0] = 0 rx[17] = 0 Before : S[0] = 0 rx[18] = 0 After : S[0] = 0 rx[18] = 0 Before : S[0] = 0 rx[19] = 0 After : S[0] = 0 rx[19] = 0 Before : S[0] = 0 rx[20] = 0 After : S[0] = 0 rx[20] = 0 Before : S[0] = 0 rx[21] = 0 After : S[0] = 0 rx[21] = 0 Before : S[0] = 0 rx[22] = 0 After : S[0] = 0 rx[22] = 0 Before : S[0] = 0 rx[23] = 0 After : S[0] = 0 rx[23] = 0 Before : S[0] = 0 rx[24] = 0 After : S[0] = 0 rx[24] = 0 Before : S[0] = 0 rx[25] = 0 After : S[0] = 0 rx[25] = 0 Before : S[1] = 0 rx[0] = 16 After : S[1] = 48 rx[0] = 16 Before : S[1] = 48 rx[1] = 140 After : S[1] = 250 rx[1] = 140 Before : S[1] = 250 rx[2] = 12 After : S[1] = 255 rx[2] = 12 Before : S[1] = 255 rx[3] = 86 After : S[1] = 167 rx[3] = 86 Before : S[1] = 167 rx[4] = 106 After : S[1] = 200 rx[4] = 106 Before : S[1] = 200 rx[5] = 110 After : S[1] = 155 rx[5] = 110 Before : S[1] = 155 rx[6] = 20 After : S[1] = 39 rx[6] = 20 Before : S[1] = 39 rx[7] = 234 After : S[1] = 77 rx[7] = 234 Before : S[1] = 77 rx[8] = 141 After : S[1] = 180 rx[8] = 141 Before : S[1] = 180 rx[9] = 247 After : S[1] = 175 rx[9] = 247 Before : S[1] = 175 rx[10] = 161 After : S[1] = 215 rx[10] = 161 Before : S[1] = 215 rx[11] = 237 After : S[1] = 139 rx[11] = 237 Before : S[1] = 139 rx[12] = 200 After : S[1] = 41 rx[12] = 200 Before : S[1] = 41 rx[13] = 197 After : S[1] = 128 rx[13] = 197 Before : S[1] = 128 rx[14] = 64 After : S[1] = 24 rx[14] = 64 Before : S[1] = 24 rx[15] = 196 After : S[1] = 1 rx[15] = 196 Before : S[1] = 1 rx[16] = 0 After : S[1] = 1 rx[16] = 0 Before : S[1] = 1 rx[17] = 1 After : S[1] = 1 rx[17] = 1 Before : S[1] = 1 rx[18] = 0 After : S[1] = 1 rx[18] = 0 Before : S[1] = 1 rx[19] = 0 After : S[1] = 1 rx[19] = 0 Before : S[1] = 1 rx[20] = 0 After : S[1] = 1 rx[20] = 0 Before : S[1] = 1 rx[21] = 0 After : S[1] = 1 rx[21] = 0 Before : S[1] = 1 rx[22] = 0 After : S[1] = 1 rx[22] = 0 Before : S[1] = 1 rx[23] = 0 After : S[1] = 1 rx[23] = 0 Before : S[1] = 1 rx[24] = 0 After : S[1] = 1 rx[24] = 0 Before : S[1] = 1 rx[25] = 0 After : S[1] = 1 rx[25] = 0 Before : S[2] = 0 rx[0] = 16 After : S[2] = 80 rx[0] = 16 Before : S[2] = 80 rx[1] = 140 After : S[2] = 255 rx[1] = 140 Before : S[2] = 255 rx[2] = 12 After : S[2] = 53 rx[2] = 12 Before : S[2] = 53 rx[3] = 86 After : S[2] = 40 rx[3] = 86 Before : S[2] = 40 rx[4] = 106 After : S[2] = 251 rx[4] = 106 Before : S[2] = 251 rx[5] = 110 After : S[2] = 179 rx[5] = 110 Before : S[2] = 179 rx[6] = 20 After : S[2] = 108 rx[6] = 20 Before : S[2] = 108 rx[7] = 234 After : S[2] = 5 rx[7] = 234 Before : S[2] = 5 rx[8] = 141 After : S[2] = 240 rx[8] = 141 Before : S[2] = 240 rx[9] = 247 After : S[2] = 202 rx[9] = 247 Before : S[2] = 202 rx[10] = 161 After : S[2] = 124 rx[10] = 161 Before : S[2] = 124 rx[11] = 237 After : S[2] = 49 rx[11] = 237 Before : S[2] = 49 rx[12] = 200 After : S[2] = 187 rx[12] = 200 Before : S[2] = 187 rx[13] = 197 After : S[2] = 146 rx[13] = 197 Before : S[2] = 146 rx[14] = 64 After : S[2] = 138 rx[14] = 64 Before : S[2] = 138 rx[15] = 196 After : S[2] = 106 rx[15] = 196 Before : S[2] = 106 rx[16] = 0 After : S[2] = 106 rx[16] = 0 Before : S[2] = 106 rx[17] = 1 After : S[2] = 106 rx[17] = 1 Before : S[2] = 106 rx[18] = 106 After : S[2] = 58 rx[18] = 58 Before : S[2] = 58 rx[19] = 0 After : S[2] = 58 rx[19] = 0 Before : S[2] = 58 rx[20] = 0 After : S[2] = 58 rx[20] = 0 Before : S[2] = 58 rx[21] = 0 After : S[2] = 58 rx[21] = 0 Before : S[2] = 58 rx[22] = 0 After : S[2] = 58 rx[22] = 0 Before : S[2] = 58 rx[23] = 0 After : S[2] = 58 rx[23] = 0 Before : S[2] = 58 rx[24] = 0 After : S[2] = 58 rx[24] = 0 Before : S[2] = 58 rx[25] = 0 After : S[2] = 58 rx[25] = 0 Before : S[3] = 0 rx[0] = 16 After : S[3] = 240 rx[0] = 16 Before : S[3] = 240 rx[1] = 140 After : S[3] = 134 rx[1] = 140 Before : S[3] = 134 rx[2] = 12 After : S[3] = 95 rx[2] = 12 Before : S[3] = 95 rx[3] = 86 After : S[3] = 63 rx[3] = 86 Before : S[3] = 63 rx[4] = 106 After : S[3] = 183 rx[4] = 106 Before : S[3] = 183 rx[5] = 110 After : S[3] = 120 rx[5] = 110 Before : S[3] = 120 rx[6] = 20 After : S[3] = 197 rx[6] = 20 Before : S[3] = 197 rx[7] = 234 After : S[3] = 219 rx[7] = 234 Before : S[3] = 219 rx[8] = 141 After : S[3] = 192 rx[8] = 141 Before : S[3] = 192 rx[9] = 247 After : S[3] = 195 rx[9] = 247 Before : S[3] = 195 rx[10] = 161 After : S[3] = 19 rx[10] = 161 Before : S[3] = 19 rx[11] = 237 After : S[3] = 96 rx[11] = 237 Before : S[3] = 96 rx[12] = 200 After : S[3] = 139 rx[12] = 200 Before : S[3] = 139 rx[13] = 197 After : S[3] = 248 rx[13] = 197 Before : S[3] = 248 rx[14] = 64 After : S[3] = 205 rx[14] = 64 Before : S[3] = 205 rx[15] = 196 After : S[3] = 63 rx[15] = 196 Before : S[3] = 63 rx[16] = 0 After : S[3] = 63 rx[16] = 0 Before : S[3] = 63 rx[17] = 1 After : S[3] = 63 rx[17] = 1 Before : S[3] = 63 rx[18] = 58 After : S[3] = 95 rx[18] = 58 Before : S[3] = 95 rx[19] = 95 After : S[3] = 140 rx[19] = 140 Before : S[3] = 140 rx[20] = 0 After : S[3] = 140 rx[20] = 0 Before : S[3] = 140 rx[21] = 0 After : S[3] = 140 rx[21] = 0 Before : S[3] = 140 rx[22] = 0 After : S[3] = 140 rx[22] = 0 Before : S[3] = 140 rx[23] = 0 After : S[3] = 140 rx[23] = 0 Before : S[3] = 140 rx[24] = 0 After : S[3] = 140 rx[24] = 0 Before : S[3] = 140 rx[25] = 0 After : S[3] = 140 rx[25] = 0 S[a^0] = 0 S[a^1] = 1 S[a^2] = 58 S[a^3] = 140 |
int S[16]
a local variable? What about int rx[26]
?That would explain everything. Local variables are not zero-initialized in C++. They contain whatever the OS and runtime environment happened to leave there.Before : S[0] = 0 rx[0] = 16 |
|
|
int rx[26], S[16];
are global variables.So, I guess that VS was intelligent as a compiler and understood that I had made it by accident |