attribute data structure rewrite

Giovanni Bajo giovannibajo@libero.it
Fri Sep 24 02:34:00 GMT 2004


Gabriel Dos Reis wrote:

> Currently, the compiler fails on any of the following fails,
> complaining about  non-"integral constant expression"-ness, which is
> pure nonense.
> 
>     const int N = 4;
>     struct S {
>       enum { M = 4 };
>       float x __attibute__((__aligned__(N)));
>       float x __attibute__((__aligned__(M)));
>     };
> 
>    template<typename T, int N>
>       struct buffer {
>          typedef char U[sizeof(T)];
>          U data __attribute__((__aligned__(N)));
>      };

Is there already a bug report about this?

Anothing thing I have been shown today is that we currently reject this:

----------------------------------------
#include <stddef.h>
#include <stdio.h>

struct A { char foo[10]; };

void bar(void) {
    int i;
    for (i=0;i<10;i++)
        printf("%d\n", offsetof(struct A, foo[i]));
}
--------------------------------------

but we used to accept it.  Any idea about its legality? Workarounds?

Giovanni Bajo




More information about the Gcc mailing list