C++ Logo

liaison

Advanced search

Re: [wg14/wg21 liaison] N2539 / P2331R0 Unsequenced functions

From: Jens Gustedt <jens.gustedt_at_[hidden]>
Date: Thu, 25 Mar 2021 11:12:06 +0100
Jens,
(also CCing Étienne, who probably is not on the liason list)
thanks for your details review, much appreciated!

It should be stated that WG14 also already had similar remarks to
yours, so we are currently revising this accordingly. I still found it
useful to have feedback from the liaison SG as early as possible, and it
seems that I was right to do so ;-)

I wouldn't go into the details below for the moment, without digging
more deeply into the text and attempting to reformulate, but I'll keep
you posted once we have something better.

Just for this one:

> Special-casing call_once in all of this seems to be very much a
> quality-of-implementation concern. Every implementation should
> choose whether it wants to teach its optimizer about the
> special "call_once" properties. (After all, this is all about
> optimizations, which are optional anyway.)

I think that I don't agree completely. The text should make guarantees
about the data dependencies that can be induced by calls to C library
functions. `call_once` is one of them, and in addition it has very
special semantics that are relevant for the properties at hand.
So something should be said in one form or another.

Thanks
Jens

on Thu, 25 Mar 2021 10:44:09 +0100 you (Jens Maurer via Liaison
<liaison_at_[hidden]>) wrote:

> These look like possibly useful attributes for C++ as well,
> but the wording needs to be totally redone.
>
> First of all, these attributes assert certain facts about a
> function to the compiler, which possibly cannot be deduced by
> the compiler.
> This is most useful if the compiler cannot "see" the definition
> of the function. However, this wording contains quite a bit
> of text talking about "is implied", meaning that the
> compiler analyzes a function definition and then implicitly
> adds the attribute to the definition. But if the
> compiler can "see" the function definition, there is little
> need for an implied attribute in the first place, because the
> compiler already has all the information it can possibly infer
> about the function (and it might inline the call anyway).
>
> I'd like to see some explanation in the prose why the "is implied"
> parts of the proposal are worth having. If "is implied" goes
> away, the wording should be rephrased in the form of
> assertions that the user makes, and should give the user
> liberty to assert any function, without further constraints
> on what the function actually does.
>
> Special-casing call_once in all of this seems to be very much a
> quality-of-implementation concern. Every implementation should
> choose whether it wants to teach its optimizer about the
> special "call_once" properties. (After all, this is all about
> optimizations, which are optional anyway.)
>
>
> - It would help me if the wording would show monospace font where the
> standard does, for example in 6.7.11.1 p2 (list of attribute names)
> and 6.7.11.6 p1 (same).
>
> - "shall only appear" -> "shall appear only"
>
> - Since the new function attributes want to apply to a function
> as declared (and not to the function type), they should apply to
> the declarator-id and not to the entire function declarator.
>
> - 6.7.11.6 p2 the first two sentences can be merged
> "... that belongs to a function declarator that declares a function."
>
> - "forms the definition" is novel phrasing, and I don't know what it
> means.
>
> - p4+5 seems to contain tutorial material that shouldn't be in
> normative text
>
> - 6.7.11.6.1 noleak: Any function -> All functions
>
> Why do we have to mention allocation functions explicitly? They
> certainly don't carry the "noleak" attribute, so the first bullet
> covers them nicely.
>
> - 6.7.11.6.1 noleak: p3 This appears to define the term "storage
> leak", but it's not used going forward. "can be deduced by the
> translator" seems vague at best: some compilers can deduce more than
> others; the specification of the standard needs to draw the line by
> explicitly saying what's going on.
>
> - p4 "with the exception of an allocated return value"
> What does that mean, exactly? When is a return value "allocated"?
> Also "shall be" sounds like a Constraint, not a Description.
>
> - 6.7.11.6.2 p2 "shall have the stateless attribute"
> That seems a bit over-the-top. This attribute is an assertion by the
> programmer to the compiler, so requiring that any called function has
> the stateless attribute seems to hinder gradual adoption in a larger
> codebase (where e.g. some third-party library function is known to be
> stateless, but not (yet) annotated as such).
>
> - 6.7.11.6.3 p2 "are const qualified variables that may range over
> the whole admissible set" This feels like "value" is missing
> somewhere, e.g. "whose values may range over..." What's the
> "admissible set" of function arguments? Using const-qualified
> variables as function arguments doesn't do anything, because the
> function parameter values are copies of those arguments anyway. Also,
> I don't think the fact that something is const-qualified is the point
> here, but the fact that no writes happen (you can choose not to write
> to a non-const variable, too).
>
> - 6.3.2.1 p4 says "A function designator is an expression that has
> function type." You say "A function designator identified by an
> identifier f" What if I have an expression of function type that is
> more than a simple identifier?
>
> - 6.7.11.6.3 p4 talks about "the" function designator, which is an
> expression. However, all that is in view here is a function
> definition. Where does the expression come from?
>
> - 6.7.11.6.4 p2 What does "objects for which the definition is met
> during the call" mean? When do you "meet" a definition?
>
> Jens
> _______________________________________________
> Liaison mailing list
> Liaison_at_[hidden]
> Subscription: https://lists.isocpp.org/mailman/listinfo.cgi/liaison
> Link to this post: http://lists.isocpp.org/liaison/2021/03/0379.php



Thanks
Jens

-- 
:: INRIA Nancy Grand Est ::: Camus ::::::: ICube/ICPS :::
:: ::::::::::::::: office Strasbourg : +33 368854536   ::
:: :::::::::::::::::::::: gsm France : +33 651400183   ::
:: ::::::::::::::: gsm international : +49 15737185122 ::
:: http://icube-icps.unistra.fr/index.php/Jens_Gustedt ::

Received on 2021-03-25 05:12:12