Re: [PATCH] handle qualified anonymous structures

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

 



On Fri, Jan 22, 2021 at 9:35 AM Linus Torvalds
<torvalds@xxxxxxxxxxxxxxxxxxxx> wrote:
>
> Anyway, looks good, and obviously passes my trivial test-case.

Oh, and then I tried a slightly more complex test-case, and didn't get
the result I expected.

In this:

    struct dummy {
        const struct {
                int a;
                volatile struct {
                        int b;
                };
        };
        int c;
    };

    int *test(struct dummy *a)
    {
        a->a = a->c;
        return &a->b;
    }

I expected to also get a warning about how we return the wrong type
(ie "&a->b" is of type "const volatile *int", but "test()" returns an
"int *").

That seems to have nothing to do with the anonymous struct type,
though. It is just because we never warn about that pointer conversion
at all.

Interestingly, It does show up as a "ptrcast" instruction in the
linearization, so I can tell that yes, sparse saw that it was a
different pointer type. It just didn't care to warn.

Not a huge deal, but I thought I'd mention it since it showed up in my test.

             Linus



[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