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

Discussion in 'C Programming' started by stsnaiv@126.com, May 21, 2013.

  1. Guest

    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 expressionthat 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 theobject,
    — 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 qualifiedversion 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, theoperation of a compound assignment is a single evaluation.


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


    Thanks everyone......
    , May 21, 2013
    #1
    1. Advertising

  2. Re: indeterminately sequenced (was: Re: three problems of C... alittle bit long but not complex.......)

    On 21-May-13 09:12, 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, May 21, 2013
    #2
    1. Advertising

  3. Re: aliases (was: Re: three problems of C... a little bit long butnot complex.......)

    On 21-May-13 09:12, 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.

    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, May 21, 2013
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. George Marsaglia

    Assigning unsigned long to unsigned long long

    George Marsaglia, Jul 8, 2003, in forum: C Programming
    Replies:
    1
    Views:
    657
    Eric Sosman
    Jul 8, 2003
  2. Daniel Rudy

    unsigned long long int to long double

    Daniel Rudy, Sep 19, 2005, in forum: C Programming
    Replies:
    5
    Views:
    1,174
    Peter Shaggy Haywood
    Sep 20, 2005
  3. Mathieu Dutour

    long long and long

    Mathieu Dutour, Jul 17, 2007, in forum: C Programming
    Replies:
    4
    Views:
    458
    santosh
    Jul 24, 2007
  4. teo
    Replies:
    3
    Views:
    444
  5. Oliver Graeser
    Replies:
    10
    Views:
    570
    Oliver Graeser
    Sep 26, 2008
Loading...

Share This Page