Pragma and noalias

T. William Wells bill at proxftl.UUCP
Tue Jun 28 07:53:11 AEST 1988


Recently, there was a posting suggesting that #pragma could be
used to tell the compiler of aliasing. Now, I am not advocating
this use, but one respondent commented that #pragma could not be
used for this purpose because it changed the semantics of the
language.

I looked up the #pragma in the standard, and all it says is that
the #pragma causes the compiler to behave in an implementation
defined manner. Now, while one could argue about just what
"implementation defined" means, I'd like to point out that using
#pragma for this purpose can't (in a correct program) be argued
against by any interpretation of "implementation defined".

My reasoning is this: in a correct program, where the #pragma
would be used, the variables referred to are IN FACT not
aliased. This means that the #pragma has NO effect on the
results of the program. However you interpret "implementation
defined", surely this falls under that heading!

The counter argument that in an incorrect program the #pragma
changes the semantics of the program in a manner which does not
have to be consistent with any kind of "implementation defined"
does not interest me: I would put optimization #pragmas only in
programs that work correctly; that is just good programming
practice. Thus, for me, this argument boils down to "the #pragma
is bad because a bad programmer will misuse it", among C
programmers, surely this particular argument is irrelevant!



More information about the Comp.lang.c mailing list