Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

three problems of C... a little bit long but not complex.......

45 views
Skip to first unread message

sts...@126.com

unread,
May 21, 2013, 10:12:40 AM5/21/13
to
what's the composite type of two sturct/union?
such as

struct f bar;
struct f
{
int member;
}bar;


it will produce a composite type? what's that?


______________________________________________________


C11 6.5p7 says that

An object shall have its stored value accessed only by an lvalue expression that has one of
the following types:
88)
— a type compatible with the effective type of the object,
— a qualified version of a type compatible with the effective type of the object,
— a type that is the signed or unsigned type corresponding to the effective type of the
object,
— a type that is the signed or unsigned type corresponding to a qualified version of the
effective type of the object,
— an aggregate or union type that includes one of the aforementioned types among its
members (including, recursively, a member of a subaggregate or contained union), or
— a character type.

The intent of this list is to specify those circumstances in which an object may or may not be aliased

so my question is what is "be aliased" ?? An object how to access using above ways?? here i can't get through so far.....


_____________________________________________



C11 6.5.2.2p10 says that
Every evaluation in the calling function (including
other function calls) that is not otherwise specifically sequenced before or after the
execution of the body of the called function is indeterminately sequenced with respect to
the execution of the called function.

what this means??


6.5.2.p2 says that

With respect to an indeterminately-sequenced function call, the operation of postfix++is a single evaluation.

and 6.5.16.2p3 says that

Acompound assignmentof the form E1op=E2 is equivalent to the simple assignment expression E1 = E1op(E2), except that the lvalue E1is evaluated only once, and with respect to an indeterminately-sequenced function call, the operation of a compound assignment is a single evaluation.


for example?? And what is the difference between indeterminately-sequenced and unsequenced??


Thanks everyone......

Stephen Sprunk

unread,
May 21, 2013, 10:46:55 AM5/21/13
to
On 21-May-13 09:12, sts...@126.com wrote:
> C11 6.5.2.2p10 says that Every evaluation in the calling function
> (including other function calls) that is not otherwise specifically
> sequenced before or after the execution of the body of the called
> function is indeterminately sequenced with respect to the execution
> of the called function.
>
> what this means??

Take this example:

a = foo() + bar();

We don't know whether foo() or bar() will be called first, but it is
guaranteed that the first one will finish executing before the second
one starts executing.

> And what is the difference between indeterminately-sequenced and
> unsequenced??

Unsequenced would allow foo() and bar() to execute at the same time.

Indeterminately sequenced means the events are sequenced but we don't
know what that sequence is.

S

--
Stephen Sprunk "God does not play dice." --Albert Einstein
CCIE #3723 "God is an inveterate gambler, and He throws the
K5SSS dice at every possible opportunity." --Stephen Hawking

Stephen Sprunk

unread,
May 21, 2013, 10:46:58 AM5/21/13
to
On 21-May-13 09:12, sts...@126.com wrote:
> C11 6.5p7 says that
>
> An object shall have its stored value accessed only by an lvalue
> expression that has one of the following types:
> 88)
> — a type compatible with the effective type of the object,
> — a qualified version of a type compatible with the effective type
> of the object,
> — a type that is the signed or unsigned type corresponding to the
> effective type of the object,
> — a type that is the signed or unsigned type corresponding to a
> qualified version of the effective type of the object,
> — an aggregate or union type that includes one of the aforementioned
> types among its members (including, recursively, a member of a
> subaggregate or contained union), or
> — a character type.
>
> The intent of this list is to specify those circumstances in which
> an object may or may not be aliased
>
> so my question is what is "be aliased" ?? An object how to access
> using above ways?? here i can't get through so far.....

Aliasing means one object may be accessed via multiple names. For instance:

int p;
int *q = &p;

In this case, *q is an alias of p: they refer to the same object. They
also happen to be of type (int), but the above list allows an alias to
have certain other types as well.
0 new messages