From: "Jan Pokorný" <pokorny_jan@seznam.cz>
To: Linux-Sparse <linux-sparse@vger.kernel.org>
Cc: Christopher Li <sparse@chrisli.org>
Subject: Re: [RFC] evaluate: pointer arithmetics on plain void*
Date: Mon, 23 Jan 2012 17:17:41 +0100 [thread overview]
Message-ID: <4F1D8825.3090308@seznam.cz> (raw)
In-Reply-To: <4F1D3741.2030604@seznam.cz>
Hi again,
On 01/23/2012 11:32 AM, Jan Pokorný wrote:
> Hm, I was talking about post-ops only, the example showed a failing pre-op
> ...both is a single case as evaluate_preop boils down to evaluate_postop.
>
> I went through evaluate.c again and I think these cases should be somehow
> unified (stating current state):
>
> 1. evaluate_postop:
> a. function: error ("bad argument type for ++/--")
> b. void*: nothing, but buggy evaluation (add/sub -1)
that "buggy evaluation" is a kind of regression that can be tracked down
to commit [1], which first started the "void != char" idea and which
missed that evaluate_postop function.
> 2. evaluate_ptr_add
> a. function: warning ("arithmetics on pointers to functions")
> b. void*: nothing, sizeof(void) implicitly considered as 1
>
> 3. evaluate_sizeof:
> a. function: warning ("expression using sizeof on a function")
> b. void: warning ("expression using sizeof(void)")
> (c. bool: warning ("expression using sizeof bool"))
>
> 4. evaluate_ptrsizeof:
> - ?
>
>
> The original patch makes 1b. an equivalent to 1a. The alternative
> is to handle 1b. in a similar way as 2b. Maybe both would deserve
> a warning.
The most moderate alternative is to take what what used in
evaluate_ptr_add into evaluate_postop.
However, the question whether to follow assumptions that GCC makes
emerges. I tried also clang -pedantic, I got:
warning: arithmetic on a pointer to void is a GNU extension
[-pedantic,-Wpointer-arith]
> Still, there is at least one inconsistency: 1a. vs 2a. (error vs warning).
[1] http://git.kernel.org/?p=devel/sparse/sparse.git;a=commit;h=405cd6e
--
Jan
--
To unsubscribe from this list: send the line "unsubscribe linux-sparse" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
next prev parent reply other threads:[~2012-01-23 16:17 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-01-22 23:31 [PATCH] evaluate: reject post-ops on void* Jan Pokorný
2012-01-23 10:32 ` [RFC] evaluate: pointer arithmetics on plain void* (was: [PATCH] evaluate: reject post-ops on void*) Jan Pokorný
2012-01-23 16:17 ` Jan Pokorný [this message]
2012-01-24 10:54 ` Christopher Li
2012-01-27 11:42 ` [PATCH] evaluate: reject post-ops on void* Christopher Li
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=4F1D8825.3090308@seznam.cz \
--to=pokorny_jan@seznam.cz \
--cc=linux-sparse@vger.kernel.org \
--cc=sparse@chrisli.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