This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
segv in memcpy on alpha
- To: bug-gcc at gnu dot org
- Subject: segv in memcpy on alpha
- From: "=?koi8-r?Q?=E7=CF=CC=D5=C2=C5=D7_=E9=CC=D8=D1_=EE?=." <gin at mo dot msk dot ru>
- Date: Thu, 21 Oct 1999 13:18:58 (GMT)
Version: 2.95.1
Platform: alpha-dec-osf4.0f
/* Compile with gcc -O2. Program gets SIGSEGV upon first call of
memcpy(). After un#if' ing #if'ed code it runs normally. */
#include<stdlib.h>
#include<string.h>
#include<stdio.h>
#include<sys/uio.h>
typedef struct iovec iovec_t;
static void f (iovec_t a);
int
main (void)
{
iovec_t w;
{
char x[16];
unsigned i;
for (i = 0; i < 8; i++) {
w.iov_base = (void *) &x[i];
w.iov_len = 4;
f (w);
printf ("memcpy () with offset %u OK\n", i);
}
}
{
void *p = malloc (4);
if (p) {
w.iov_base = p;
w.iov_len = 4;
f (w);
printf ("memcpy () of malloc ()'ed data OK\n");
free (p);
}
}
return 0;
}
static void g (size_t s);
static void
f (iovec_t w)
{
unsigned int s;
if (w.iov_len == sizeof s) {
#if 0
g (w.iov_len);
#endif /* 0 */
memcpy ((void *)&s, w.iov_base, w.iov_len);
}
}
static void
g (size_t s)
{
}