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,446 of 243,242   
   Keith Thompson to Keith Thompson   
   Re: bugprone-switch-missing-default-case   
   23 Oct 25 19:13:31   
   
   From: Keith.S.Thompson+u@gmail.com   
      
   Keith Thompson  writes:   
   > pozz  writes:   
   >> Il 22/10/2025 21:41, Keith Thompson ha scritto:   
   > [...]   
   >>> That document is poorly written.  The phrase "without any defined   
   >>> behavior" strongly implies that the behavior is undefined, which is   
   >>> simply wrong.   
   >>> It says:   
   >>>      When a switch statement lacks a default case, if a value is   
   >>>      encountered that does not match any of the specified cases, the   
   >>>      program will continue execution without any defined behavior or   
   >>>      handling.   
   >>> It would be more accurate to say:   
   >>>      When a switch statement lacks a default case, if a value is   
   >>>      encountered that does not match any of the specified cases, the   
   >>>      switch statement will do nothing and the program will continue   
   >>>      execution without handling the value.   
   >>> A warning might be warranted, but the behavior is well defined.   
   >>   
   >> It is exactly what i wanted to read. Thanks for the explanation.   
   >>   
   >>> Note that the documentation is for the add-on tool clang-tidy, not for   
   >>> the clang compiler.   
   >>   
   >> Sure   
   >>   
   >>   
   >>> I've submitted a bug report :   
   >>> https://github.com/llvm/llvm-project/issues/164699   
   >   
   > My fix for this has been accepted into the llvm-project git repo.   
   >   
   > The web page   
   > https://clang.llvm.org/extra/clang-tidy/checks/bugprone/switch   
   missing-default-case.html   
   > has not yet been updated (not surprisingly).   
      
   And now it's been updated:   
      
       Switch statements without a default case can lead to unexpected   
       behavior and incomplete handling of all possible cases. When a   
       switch statement lacks a default case, if a value is encountered   
       that does not match any of the specified cases, the switch   
       statement will do nothing and the program will continue execution   
       without handling the value.   
      
   --   
   Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com   
   void Void(void) { Void(); } /* The recursive call of the void */   
      
   --- 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