Re: [PATCH] handle qualified anonymous structures

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

 



On Fri, Jan 22, 2021 at 10:01:40AM -0800, Linus Torvalds wrote:
> 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.

Thank you to mention this.
It's because once an error has been issued, warnings are not displayed
anymore. For example, the following will return the expected warning:
	int *test(struct dummy *a)
	{
		return &a->b;
	}
 
I think it's something that made a lot of sense before but which is
more and more annoying because it hides legitimate warnings, like here
(of course, it also hides silly/'second order' warnings).

-- Luc



[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