"Noalias" warning and questions
Larry Jones
scjones at sdrc.UUCP
Sat Feb 13 09:06:34 AEST 1988
In article <8012 at elsie.UUCP>, ado at elsie.UUCP (Arthur David Olson) writes:
< [stuff about noalias]
<
< Now a bit of background for a few questions. Here are two function prototypes
< from the proposed Standard:
< int strcmp(const noalias char *s1, const noalias char *s2);
< void perror(const noalias char *s);
<
< 1. Does the program
< #include "stdlib.h"
< main() {
< char array[3];
< array[0] = '\0';
< return strcmp(array, array);
< }
< violate any constraints? If so, must the compiler detect the violation?
<
< [other similar examples]
Nope, no problems here. The definition of noalias doesn't forbid aliases, it
just says that if you do have aliases and >modify< one of them, all bets are
off. Since strcmp() doesn't modify any of its arguments (as evidenced by the
"const"), your examples are all fine and dandy.
< 4. What is the "noalias" in the "perror" declaration designed to do?
The same thing as it does in the "strcmp" declaration - basically nothing.
It's really only applicable to output arguments but we decided to put it
on all the library pointers for consistency's sake.
--
----
Larry Jones UUCP: uunet!sdrc!scjones
SDRC MAIL: 2000 Eastman Dr., Milford, OH 45150
AT&T: (513) 576-2070
"When all else fails, read the directions."
More information about the Comp.lang.c
mailing list