* On 2013 01 Jan 14:14 -0600, Zbigniew Komarnicki wrote: > On Tuesday 01 of January 2013 08:23:05 you wrote: > > C lessons today? (There are newsgroups for C and C++ questions, but, why > > not?) > > Yes :-) > > I wanted to prohibit user to assign negative value to a variable. > This variable is later passed to a recurrence function as > argument and of course I got segmentation fault, because > the function is called 4294967291 times.
Then you will need to bounds test the user input. > > I was very surprised when I discover that this code was compiled > without any warning. I thought if a variable is 'unsigned int' > then this is not allowed to assign negative value. Consider instead that the code is giving you the value of MAX UNSIGNED INT - 5. In other words, the code is allowing you to count backwards from the maximum integer unsigned value on your system. That's how I understand it. - Nate -- "The optimist proclaims that we live in the best of all possible worlds. The pessimist fears this is true." Ham radio, Linux, bikes, and more: http://www.n0nb.us -- To UNSUBSCRIBE, email to debian-user-requ...@lists.debian.org with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org Archive: http://lists.debian.org/20130101203334.gr1...@n0nb.us