S
stefano.verna
I would be grateful to anybody who can explain what on earth is going
wrong. I have this tiny little piece of code:
void sendOperation16 (int fd, int16_t o1, int16_t o2) {
unsigned char response[3] = { '=', 0 };
int16_t *p = (int16_t *) (response+1);
/* ..some overflow error management here.. */
o1+=o2;
memcpy (p, &o1, 2);
Writen (fd, response, 3);
}
On Linux/Cygwin it works as is should. On Solaris, the memcpy
statement will cause the program to be terminated. I really don't know
what to think about, as at these lines are perfectly normal and
compliant to me.
If i simply change it to
memcpy (response+1, &o1, sizeof (o1));
it works again.
wrong. I have this tiny little piece of code:
void sendOperation16 (int fd, int16_t o1, int16_t o2) {
unsigned char response[3] = { '=', 0 };
int16_t *p = (int16_t *) (response+1);
/* ..some overflow error management here.. */
o1+=o2;
memcpy (p, &o1, 2);
Writen (fd, response, 3);
}
On Linux/Cygwin it works as is should. On Solaris, the memcpy
statement will cause the program to be terminated. I really don't know
what to think about, as at these lines are perfectly normal and
compliant to me.
If i simply change it to
memcpy (response+1, &o1, sizeof (o1));
it works again.