https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100920

--- Comment #9 from George Thopas <george.thopas at gmail dot com> ---
/*
Hi Eric,

1) I noticed there's a typo in the test, (which is my fault) and may give
   unexpected behavior later on

    memcpy(msg2, &msg1, sizeof(t_s12));
     => should be  memcpy(msg2, msg1, sizeof(t_s12));

2) Trying to get a platform built free of these warning, I still see quite some
which match below example.  
Raising one for these cases is really problematic. Functions using void in
stead of an explicit type are explicitly saying that the type does not matter.
There never is a warning for any other type where you pass them. so
I hope  you can give this one another go.

Thanks again for your patience.

*/


#include <stddef.h>
#include <string.h>

#define SIZE 10

struct be {
    int a;
    int b; 
} __attribute__((scalar_storage_order("big-endian")));

typedef struct be t_be;

struct le {
    int a;
    int b; 
} __attribute__((scalar_storage_order("little-endian")));

typedef struct le t_le;


void memset2(void *s, char c, int n)
{
   char *d=(char *)s;
   for(int i=0;i<n;i++)
      d[n]=c;
}

void init(void *data, int len)
{
    memset(data,0xcf, len);
}

int main(void)
{
    t_be *d0 = __builtin_alloca(SIZE);
    t_le *d1 = __builtin_alloca(SIZE);
    t_be *d2 = __builtin_alloca(SIZE);
    t_le *d3 = __builtin_alloca(SIZE);    
    void *raw  = __builtin_alloca(SIZE);

    init(d0, SIZE);
    init(d1, SIZE);
    init(d2, SIZE);
    init(d3, SIZE);
    init(raw, SIZE);    

    memset2(d0, 0xcf, SIZE);
    memset2(d1, 0xcf, SIZE);
    memset2(d2, 0xcf, SIZE);
    memset2(d3, 0xcf, SIZE);
    memset2(raw, 0xcf, SIZE);

    return 0;
}

Reply via email to