Re: typedefs and alignment

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, Feb 8, 2010 at 2:35 AM, Dan Carpenter <error27@xxxxxxxxx> wrote:
> I've found an issue handling typedefs and alignment.  In the appended
> code sparse things 'ptr' has to be aligned so the size of 'bar' is 1024.
> I haven't looked at how to fix this at all, I thought I would ask the
> experts for hints first.

Hmm, there is a bug there.

For the simplified code:

typedef struct aligned_struct {
       int a;
}  __attribute__ ((aligned(1024))) ali_t;

ali_t *ppr;

running test-parsing will show:

.align 1024
struct aligned_struct [usertype] *[addressable] [toplevel] ppr

I am looking at it right now.

Chris



>
> regards,
> dan carpenter
>
> #include <stdio.h>
>
> typedef struct aligned_struct {
>        int a;
> }  __attribute__ ((aligned(1024))) ali_t;
>
> struct foo {
>        int b;
>        ali_t *ptr;
> };

It does look wrong. The easier way to expose it


>
> int mainx(void)
> {
>        struct foo bar;
>
>        printf("%d\n", sizeof(bar));
>        return 0;
> }
> --
> To unsubscribe from this list: send the line "unsubscribe linux-sparse" in
> the body of a message to majordomo@xxxxxxxxxxxxxxx
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>
--
To unsubscribe from this list: send the line "unsubscribe linux-sparse" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Newbies FAQ]     [LKML]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Trinity Fuzzer Tool]

  Powered by Linux