Re: General remarks on restrict
- From: "Charlie Gordon" <news@xxxxxxxxxxx>
- Date: Fri, 19 Sep 2008 11:58:03 +0200
"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.
.
- Follow-Ups:
- Re: General remarks on restrict
- From: Hallvard B Furuseth
- Re: General remarks on restrict
- References:
- restrict vs. threads
- From: Hallvard B Furuseth
- Re: restrict vs. threads
- From: Eric Sosman
- Re: restrict vs. threads
- From: Hallvard B Furuseth
- Re: restrict vs. threads
- From: Hallvard B Furuseth
- General remarks on restrict (was: restrict vs. threads)
- From: Charlie Gordon
- Re: General remarks on restrict
- From: Ian Collins
- Re: General remarks on restrict
- From: Charlie Gordon
- Re: General remarks on restrict
- From: Ian Collins
- Re: General remarks on restrict
- From: Wojtek Lerch
- Re: General remarks on restrict
- From: Bart van Ingen Schenau
- restrict vs. threads
- Prev by Date: Re: General remarks on restrict
- Next by Date: Re: General remarks on restrict
- Previous by thread: Re: General remarks on restrict
- Next by thread: Re: General remarks on restrict
- Index(es):
Relevant Pages
|