Regarding behavior of code:

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • coolguyaroundyou@gmail.com

    Regarding behavior of code:

    See the following code snippet:

    {
    int a=1;
    printf("%d %d %d",a,++a,a++ );
    }

    Will the behavior be undefined/unspecifed or no such thing? Please
    state reasons, along with your post(s).
  • Richard Heathfield

    #2
    Re: Regarding behavior of code:

    coolguyaroundyo u@gmail.com said:
    See the following code snippet:
    >
    {
    int a=1;
    printf("%d %d %d",a,++a,a++ );
    }
    >
    Will the behavior be undefined/unspecifed or no such thing?
    Undefined.
    Please state reasons, along with your post(s).
    Same reason it was undefined the other eight million times it was asked.

    --
    Richard Heathfield <http://www.cpax.org.uk >
    Email: -http://www. +rjh@
    Google users: <http://www.cpax.org.uk/prg/writings/googly.php>
    "Usenet is a strange place" - dmr 29 July 1999

    Comment

    • coolguyaroundyou@gmail.com

      #3
      Re: Regarding behavior of code:

      On Oct 11, 12:02 pm, Richard Heathfield <r...@see.sig.i nvalidwrote:
      coolguyaround.. .@gmail.com said:
      >
      See the following code snippet:
      >
      {
      int a=1;
      printf("%d %d %d",a,++a,a++ );
      }
      >
      Will the behavior be undefined/unspecifed or no such thing?
      >
      Undefined.
      >
      Please state reasons, along with your post(s).
      >
      Same reason it was undefined the other eight million times it was asked.
      >
      --
      Richard Heathfield <http://www.cpax.org.uk >
      Email: -http://www. +rjh@
      Google users: <http://www.cpax.org.uk/prg/writings/googly.php>
      "Usenet is a strange place" - dmr 29 July 1999
      Why do you say undefined and not unspecified?

      Comment

      • Richard Heathfield

        #4
        Re: Regarding behavior of code:

        coolguyaroundyo u@gmail.com said:
        On Oct 11, 12:02 pm, Richard Heathfield <r...@see.sig.i nvalidwrote:
        >coolguyaround. ..@gmail.com said:
        >>
        See the following code snippet:
        >>
        {
        int a=1;
        printf("%d %d %d",a,++a,a++ );
        }
        >>
        Will the behavior be undefined/unspecifed or no such thing?
        >>
        >Undefined.
        >>
        Please state reasons, along with your post(s).
        >>
        >Same reason it was undefined the other eight million times it was asked.
        >>
        Why do you say undefined and not unspecified?
        Same reason it was undefined the other eight million times it was asked.
        Quoth the Standard: "Between the previous and next sequence point an
        object shall have its stored value modified at most once by the evaluation
        of an expression. Furthermore, the prior value shall be accessed only to
        determine the value to be stored."

        Note the uses of the word "shall". And these are "shall"s that are not part
        of a constraint.

        "In this Standard, ``shall'' is to be interpreted as a requirement
        on an implementation or on a program; conversely, ``shall not'' is to
        be interpreted as a prohibition."

        "If a ``shall'' or ``shall not'' requirement that appears outside of a
        constraint is violated, the behavior is undefined."

        --
        Richard Heathfield <http://www.cpax.org.uk >
        Email: -http://www. +rjh@
        Google users: <http://www.cpax.org.uk/prg/writings/googly.php>
        "Usenet is a strange place" - dmr 29 July 1999

        Comment

        Working...