On 06/03/2016 09:23 AM, Jakub Jelinek wrote:
On Fri, Jun 03, 2016 at 09:07:09AM -0600, Martin Sebor wrote:
I'm not sure I understand your concern but at this point I would
prefer to keep things as they are. I like that the functionality
My concern is that if you declare that NULL is valid third argument for e.g.
__builtin_add_overflow, then unless we add some complicated wording into the
docs,
Thanks the clarification.
Trying to document that the third argument may be NULL, but only if it is
constant NULL pointer expression or something like that (what exactly?)
might not be very easily understandable and clear to users.
I think the updated wording is quite clear:
The first of the functions accepts either a pointer to an integer
object or a null pointer constant.
/A null pointer constant/ is a basic term defined by both C and C++
so it should be familiar to all C++ programmers. (To make it 100%
correct we should perhaps say:
"...or a null pointer constant cast to a pointer to integer."
even though that should be obvious since the functions won't
accept a bare NULL.)
Which is why I've suggested just not allowing (like before) the third
argument to be NULL, and just add new 3 builtins for the test for overflow,
but don't store it anywhere. They would just be folded early to the same
internal function. And when adding the 3 new builtins, we can also choose
a different calling convention that would allow the C++98/C constant
expressions, by not having the third argument a pointer (we don't need to
dereference anything), but e.g. just any integer where we ignore the value
(well, evaluate for side-effects) and only care about the type.
I understand what you're suggesting and it's something I could
have easily done when I started on it a few weeks ago but I'm
afraid really out of cycles to continue to tweak the patch.
I think it's good enough as it is for now, gives the requester
what they asked for and lets me finish the C++ VLA bounds
checking, which is the main reason why I did this work to begin
with. We can revisit this idea when we get the requester's
feedback (and after I've made some headway on my pending tasks).
Does that sound reasonable?
Martin