Path: ...!eternal-september.org!feeder2.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: Bart Newsgroups: comp.lang.c Subject: Re: else ladders practice Date: Fri, 8 Nov 2024 17:37:20 +0000 Organization: A noiseless patient Spider Lines: 66 Message-ID: References: <3deb64c5b0ee344acd9fbaea1002baf7302c1e8f@i2pn2.org> <6724CFD2.4030607@grunge.pl> <2491a699388b5891a49ef960e1ad8bb689fdc2ed@i2pn2.org> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Injection-Date: Fri, 08 Nov 2024 18:37:19 +0100 (CET) Injection-Info: dont-email.me; posting-host="33e6c63f87222477390301c1377b09f9"; logging-data="3467237"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18WVGKQ+hoc8eQ4yCw1Sf+Z" User-Agent: Mozilla Thunderbird Cancel-Lock: sha1:TIDn1r70KluBuXH4t7Hnq/HRsFU= Content-Language: en-GB In-Reply-To: Bytes: 3873 On 08/11/2024 08:45, David Brown wrote: > On 07/11/2024 13:23, Bart wrote: >> On 06/11/2024 14:50, David Brown wrote: >>> On 05/11/2024 23:48, Bart wrote: >>>> On 05/11/2024 13:29, David Brown wrote: >> >>>>> int small_int_sqrt(int x) { >>>>>      if (x == 0) return 0; >>>>>      if (x < 4) return 1; >>>>>      if (x < 9) return 2; >>>>>      if (x < 16) return 3; >>>>>      unreachable(); >>>>> } >> >>> "unreachable()" is a C23 standardisation of a feature found in most >>> high-end compilers.  For gcc and clang, there is >>> __builtin_unreachable(), and MSVC has its version. >> >> So it's a kludge. > You mean it is something you don't understand?  Think of this as an > opportunity to learn something new. You don't seem to understand a 'kludge' is. Think of it as a 'hack', something bolted-on to a language. This is from Hacker News about 'unreachable': "Note that gcc and clang's __builtin_unreachable() are optimization pragmas, not assertions. If control actually reaches a __builtin_unreachable(), your program doesn't necessarily abort. Terrible things can happen such as switch statements jumping into random addresses or functions running off the end without returning:" "Sure, these aren't for defensive programming—they're for places where you know a location is unreachable, but your compiler can't prove it for you." >> 'dummyelse' is a special version of 'else' that tells the compiler >> that control will (should) never arrive there. ATM it does nothing but >> inform the reader of that and to remind the author. But later stages >> of the compiler can choose not to generate code for it, or to generate >> error-reporting code. >> > > You are missing the point - that is shown clearly by the "int.min". At least my code will never 'run off the end of a function'. But, it looks like you're happy with ensuring C programs don't do that, by the proven expedient of keeping your fingers crossed. > You have your way of doing things, and have no interest in learning > anything else or even bothering to listen or think. Ditto for you. >  Your bizarre hatred > of C is overpowering for you Ditto for your hatred of my stuff.