Warnings when using % operator

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Martin

    #16
    Re: Warnings when using % operator

    Tim wrote:[color=blue]
    > ... The signed/unsigned comparison in the
    > 'for' control clause gets flagged with a
    > warning. Am I on track?[/color]

    Sort of. In fact, Ben explained the problem in his response to me:

    "When `a' and `b' are unsigned, `a % b'
    is always nonnegative. Thus, ((i) % (j)) < 0
    is always false in this case, hence the
    first warning. That subexpression is the
    first part of a ?: expression, hence the
    second warning." -- Ben, 15 Sep 2004

    So the problem arises when the IMOD macro is used. Regarding your
    suggestion, I note that Plauger says:

    "You should make a point of using type
    size_t *anywhere* your program
    performs array subscripting or address
    arithmetic."
    -- P.J. Plauger, The Standard C Library

    Thanks for your post.

    Martin




    Comment

    • Martin

      #17
      Re: Warnings when using % operator

      "Eric Sosman" wrote:[color=blue]
      > Yes, but this latest question baffles me. What
      > are you getting at?[/color]

      Eric, I was puzzled by the sudden break in sentence, you wrote "why not" and
      then quoted my IMOD definition.

      Martin




      Comment

      • Eric Sosman

        #18
        Re: Warnings when using % operator

        Martin wrote:[color=blue]
        > "Eric Sosman" wrote:
        >[color=green]
        >> Yes, but this latest question baffles me. What
        >>are you getting at?[/color]
        >
        >
        > Eric, I was puzzled by the sudden break in sentence, you wrote "why not" and
        > then quoted my IMOD definition.[/color]

        Ah, now I see. If you'll re-read my post you'll find
        that one of the six lines is not a quote, but differs from
        your original version. The changed line is my contribution
        (FWIW); the others were just for context. Sorry if they
        misled you.

        --
        Eric.Sosman@sun .com

        Comment

        Working...