| Deutsch English Français Italiano |
|
<vgli8f$39pv5$1@dont-email.me> View for Bookmarking (what is this?) Look up another Usenet article |
Path: ...!eternal-september.org!feeder2.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Bart <bc@freeuk.com>
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: <vgli8f$39pv5$1@dont-email.me>
References: <3deb64c5b0ee344acd9fbaea1002baf7302c1e8f@i2pn2.org>
<vg2g37$37mh3$1@dont-email.me> <6724CFD2.4030607@grunge.pl>
<vg2llt$38ons$1@dont-email.me>
<2491a699388b5891a49ef960e1ad8bb689fdc2ed@i2pn2.org>
<b681ee05856e165c26a5c29bf42a8d9d53843d6d@i2pn2.org>
<vg2ttn$3a4lk$1@dont-email.me> <vg33gs$3b8n5$1@dont-email.me>
<vg358c$3bk7t$1@dont-email.me> <vg37nr$3bo0c$1@dont-email.me>
<vg3b98$3cc8q$1@dont-email.me> <vg5351$3pada$1@dont-email.me>
<vg62vg$3uv02$1@dont-email.me> <vgd3ro$2pvl4$1@paganini.bofh.team>
<vgd6jh$1hmjc$1@dont-email.me> <vge7bt$1o57r$1@dont-email.me>
<vgfvne$25kug$1@dont-email.me> <vgibf8$2l858$1@dont-email.me>
<vgkj38$34d5t$1@dont-email.me>
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: <vgkj38$34d5t$1@dont-email.me>
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.