home bbs files messages ]

Forums before death by AOL, social media and spammers... "We can't have nice things"

   comp.lang.c      Meh, in C you gotta define EVERYTHING      243,242 messages   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]

   Message 241,384 of 243,242   
   James Kuyper to David Brown   
   Re: signed vs unsigned and gcc -Wsign-co   
   21 Oct 25 14:44:46   
   
   From: jameskuyper@alumni.caltech.edu   
      
   On 2025-10-21 06:42, David Brown wrote:   
   > On 20/10/2025 22:09, Kaz Kylheku wrote:   
   >> On 2025-10-20, David Brown  wrote:   
   >>> On 20/10/2025 17:03, pozz wrote:   
   ...>> However using unsigned types due to them being safe is often poorly   
   >> considered because if something goes wrong contrary to the programmer's   
   >> intent, there likely will be undefined behavior somewhere.   
   >   
   > Exactly.  Unsigned types are not somehow "safer" than signed types, just   
   > because signed types have UB on overflow.  Don't overflow your signed   
   > types, then you have no UB.  And if you overflow your unsigned types   
   > without that being an intentional and understood part of your code, you   
   > will at the very least get unexpected behaviour - a bug - and just like   
   > UB, there are no limits to how bad that can get.   
      
   No, there are limits on unexpected behavior: being unexpected, you might   
   not know what they are, but it is still the case that the behavior   
   starts out with having nothing more than an expression with an   
   unexpected but valid value. That's pretty bad, and your code might make   
   it worse, for example by promoting the unexpected value into undefined   
   behavior. However, unless and until it actually does so, the behavior is   
   somewhat more restricted than UB.   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]


(c) 1994,  bbs@darkrealms.ca