1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

VS2010 - Is this a bug?

Discussion in 'C++' started by VBNick, Sep 10, 2010.

  1. VBNick

    VBNick New Member

    Sep 10, 2010
    Likes Received:
    Trophy Points:
    I was trying to make a for loop count down backwards using this loop, but when it gets to zero, instead of realizing that decrementing will bring the number below zero, it tries to make the unsigned short (-1), which is actually 65535 as unsigned.

    of course, this code produces an access violation because there is no elements 65535.

    for(unsigned short i = n_elements - 1; i >= 0; i--)
    array = blah;

Share This Page