[Tips] noAlias에 관해서 조사해봤습니다.
## 아직은 제대로 이해하지 못하고 있습니다 ;; 혹시라도 궁금하셨던 분들은 한번 읽어보세요~
alias = 하나의 프로그램에서 동일한 기억 장소를 참조하는 변수에 둘 이상의 이름이 붙은 것.
noalias
C 언어를 처음 표준화하던 시기에 컴파일러에게 두 대상체가 서로 에일리어징되지 않았음을 확신시키기 위한 방법으로 noalias라는 형 한정어(type qualifier)를 도입하려 했다. 하지만 이 형 한정어는 상당히 엄격하고 복잡한 의미를 가지고 있어 제대로 기술하기도 쉽지 않았고, 이를 도입할 경우 언어에 심각한 오점을 만들 가능성도 있기에 심한 반대에 부딪혀 결국 표준에 입성하지 못했다
Noalias: excerpt from the ANSI C draft of January 1988 Source
--------------------------------------------------------------------------------
For the sake of history, I record the portion dealing with the semantics of noalias in X3J11's draft C standard as of Jan 1988. It's been manually detroffed; apologies for errors.
I had problems convincing myself that the notion of handle (see below) was well defined, and in understanding the consequences of the described semantics. As my diatribe tells, though, the ultimate problem was that the model these semantics propose is wrong: ``noaliasness'' is not a useful property of objects, but is better understood in terms of promises about what pointers can point to.
Dennis Ritchie
Here's the snippet from the draft:
Semantics
The properties associated with qualified types are meaningful only for expressions that are lvalues.
Each lvalue that is a unary expression with the unary * indirection operator (either explicitly or as a result of the array subscript [] operator) contains one or more handles. These handles have pointer or array type and are the smallest expressions contained within the lvalue (ignoring the left operand of the comma operator, the operand of the sizeof operator, all argument expressions, and all expressions with integral type), and are associated with the entire object to which the lvalue refers, in part or as a whole. The handles for lvalues with noalias-qualified type are noalias handles. A handle is distinguished by the spelling of its operands (ignoring the spelling of any contained argument expressions) and by the storage duration of its handle objects, those objects whose values are accessed to evaluate the handle (excluding any objects accessed to evaluate any contained argument expressions).
The actual object of a noalias handle is the entire object of which a part is designated by the same lvalue except that its type is the nonnoaliasqualified version. For each distinct noalias handle, it is unspecified whether the handle is associated with the actual object or is associated with a virtual object, a distinct object with the same size and address as the actual object. The behavior of a program that depends upon a specific implementation choice is undefined.
A virtual object, if and when created, acquires the laststored value of the actual object. A virtual object may be created at any sequence point within a function for which there exists a sequence point at which the storage for all handle objects is guaranteed to be reserved. A virtual object has a pending value if it has been modified through use of its noalias handle and the actual object does not have the same value. All virtual objects with pending values for a noalias handle have their values assigned to their respective actual objects at the return of a function after whose execution storage is no longer guaranteed to be reserved for a handle object of the noalias handle.
If an argument expression is a noalias handle, or is a noalias handle plus or minus an expression with integral type (either explicitly or as a result of combinations of the unary & address operator and the array subscript [] operator), just after the return from the function, the value stored in the actual object is assigned to the currently associated virtual object, if any exists.
[Footnote: If the called function has a type that includes a prototype and the type of the parameter is a pointer to a const- and noalias-qualified type, this assignment can be suppressed, as the called function cannot modify the designated object.]
Furthermore, if, at the sequence point just before the call to the function, the noalias handle is currently associated with a virtual object with a pending value, its value is assigned to the actual object at that sequence point.
[Dicussion of volatile qualifier deleted--dmr]
The following are examples of some lvalues and their handles:
int a[2], b[3][4], i;
int *p, **q, *f();
a[1]; /* same as *(a + 1), handle: a */
b[i][2]; /* same as *(b[i] + 2), handle: b */
*p; /* handle: p */
*(p + i); /* handle: p */
*(i = 4, p); /* handle: p */
*f(); /* handle: f() */
**(q + i); /* handle: *(q + i) */
Prisms
Fri, 01/25/2008 - 08:08
Permalink
Re: noAlias에 관해서 조사해봤습니다.
좋은 정보 감사합니다. 이걸 어떻게 정리하는 것이 좋겠습니까?