Re: General remarks on restrict



"Bart van Ingen Schenau" <Bart.van.Ingen.Schenau@xxxxxx> a écrit dans le
message de news:
e30bf715-5244-4f18-ac48-6b4ed998e0d7@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
On Sep 18, 3:06 pm, "Wojtek Lerch" <Wojte...@xxxxxxxx> wrote:
"Ian Collins" <ian-n...@xxxxxxxxxxx> wrote in message

news:6jem7pF2rfhgU12@xxxxxxxxxxxxxxxxxxxxx

The use of restrict clearly differentiates between the behaviour of
memcpy and that of memmove.

No, the use of restrict to qualify parameters in a function declaration
(that is not a definition) is meaningless.

It might not carry a meaning that the compiler can enforce, but the
qualification *does* carry a meaning for the human programmer who uses
memcpy.
The restrict qualification conveys the information that the function
can not be safely used with pointers that refer to (partially)
overlapping memory areas.

That's exactly my point: many programmers seem to believe that, but they are
mistaken.
The restrict keyword in the declaration does not convey anything at all.
What you are describing here is intent, not fact. The information you say
in conveyed is nothing more than a hint for the human reader, just like the
names for the function parameters in the declaration.
Information about the constraints on memcpy's parameters would be better
conveyed with a comment than the use of poorly understood keywords in a
meaningless context.

Qualifiers on parameters have no
bearing on function type compatibility or on the semantics of the
function
call operator. Adding or removing the qualifiers in a function
declaration
has absolutely no effect on the meaning of the program.

I think they should be removed. They only add confusion.

--
Chqrlie.


.



Relevant Pages

  • Re: General remarks on restrict
    ... qualification *does* carry a meaning for the human programmer who uses ... This means that a function type with restrict-qualified parameters is compatible with a similar function type that declares the parameters without the restrict qualifier. ... In a C program, the names and qualifiers of parameters in a function declaration are meaningless, in the sense that a compatible definition is free to declare the parameters with different names and qualifiers, and any semantics associated with qualifiers depend on the qualifiers used in the definition, not the ones used in the declaration. ... Does the standard say anywhere that the qualifiers in the synopsis of a standard library function carry more meaning than they do in an identically looking declaration in a C program? ...
    (comp.std.c)
  • Re: General remarks on restrict
    ... The meaning of the restrict qualifier is specified in detail in clause ... is free to declare the parameters with different names and qualifiers, ... not the ones used in the declaration. ...
    (comp.std.c)
  • Re: A DECLARATION OF MEANING
    ... > is just a declaration of meaning and not a thesis. ... If we define fitness as being that which is maximised by the action of ... Note that John Edser wrote: ...
    (sci.bio.evolution)
  • Re: Sampras wins in tight five-setters ...
    ... qualification, and even then it's pretty much subjective. ... the loss would have had virtually no meaning beyond the AO itself. ... If the number of important matches lost in a career (or ...
    (rec.sport.tennis)
  • Re: Sampras wins in tight five-setters ...
    ... qualification, and even then it's pretty much subjective. ... the loss would have had virtually no meaning beyond the AO itself. ... If the number of important matches lost in a career (or ...
    (rec.sport.tennis)