Linux-Sparse Archive mirror
 help / color / mirror / Atom feed
From: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
To: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Sparse Mailing-list <linux-sparse@vger.kernel.org>
Subject: Re: [PATCH] handle qualified anonymous structures
Date: Fri, 22 Jan 2021 21:11:56 +0100	[thread overview]
Message-ID: <20210122201156.7knkorg7yqr3dwdp@mail> (raw)
In-Reply-To: <CAHk-=wiGgNEWybdqu1pmV_zCXJ+woyni2ie3+2pnFZfzwY8NEA@mail.gmail.com>

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@linux-foundation.org> 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

  reply	other threads:[~2021-01-22 21:30 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-20 19:21 'const' unnamed structures Linus Torvalds
2021-01-20 22:55 ` Luc Van Oostenryck
2021-01-22 16:26 ` [PATCH] handle qualified anonymous structures Luc Van Oostenryck
2021-01-22 17:35   ` Linus Torvalds
2021-01-22 18:01     ` Linus Torvalds
2021-01-22 20:11       ` Luc Van Oostenryck [this message]
2021-01-22 19:38     ` Luc Van Oostenryck

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210122201156.7knkorg7yqr3dwdp@mail \
    --to=luc.vanoostenryck@gmail.com \
    --cc=linux-sparse@vger.kernel.org \
    --cc=torvalds@linux-foundation.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).