Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

RIP is irrelevant. Spoofing is futile. Your routes will be aggregated. -- Alex Yuriev


devel / comp.lang.c / Re: strong types in c - (safety samples)

SubjectAuthor
* strong types in c - (safety samples)Thiago Adams
+* Re: strong types in c - (safety samples)Thiago Adams
|`* Re: strong types in c - (safety samples)Thiago Adams
| `* Re: strong types in c - (safety samples)Keith Thompson
|  +* Re: strong types in c - (safety samples)David Brown
|  |`- Re: strong types in c - (safety samples)Keith Thompson
|  `* Re: strong types in c - (safety samples)Thiago Adams
|   `* Re: strong types in c - (safety samples)Chris M. Thomasson
|    `- Re: strong types in c - (safety samples)Keith Thompson
+* Re: strong types in c - (safety samples)Kaz Kylheku
|+* Re: strong types in c - (safety samples)Thiago Adams
||`- Re: strong types in c - (safety samples)Keith Thompson
|`* Re: strong types in c - (safety samples)Malcolm McLean
| `- Re: strong types in c - (safety samples)Ben Bacarisse
+* Re: strong types in c - (safety samples)Tim Rentsch
|`* Re: strong types in c - (safety samples)Thiago Adams
| `* Re: strong types in c - (safety samples)Tim Rentsch
|  `- Re: strong types in c - (safety samples)Thiago Adams
+- Re: strong types in c - (safety samples)Blue-Maned_Hawk
`* Re: strong types in c - (safety samples)Thiago Adams
 +* Re: strong types in c - (safety samples)Keith Thompson
 |`* Re: strong types in c - (safety samples)Thiago Adams
 | +* Re: strong types in c - (safety samples)Thiago Adams
 | |+- Re: strong types in c - (safety samples)Keith Thompson
 | |`* Re: strong types in c - (safety samples)David Brown
 | | `* Re: strong types in c - (safety samples)bart
 | |  +* Re: strong types in c - (safety samples)Thiago Adams
 | |  |`- Re: strong types in c - (safety samples)Thiago Adams
 | |  +* Re: strong types in c - (safety samples)Kaz Kylheku
 | |  |`- Re: strong types in c - (safety samples)Janis Papanagnou
 | |  `- Re: strong types in c - (safety samples)David Brown
 | `- Re: strong types in c - (safety samples)Thiago Adams
 `- Re: strong types in c - (safety samples)David Brown

Pages:12
Re: strong types in c - (safety samples)

<ur0tp1$25adf$2@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=33546&group=comp.lang.c#33546

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: thiago.a...@gmail.com (Thiago Adams)
Newsgroups: comp.lang.c
Subject: Re: strong types in c - (safety samples)
Date: Mon, 19 Feb 2024 22:03:28 -0300
Organization: A noiseless patient Spider
Lines: 7
Message-ID: <ur0tp1$25adf$2@dont-email.me>
References: <uqb741$13gk8$1@dont-email.me> <ur067b$20k5b$1@dont-email.me>
<87bk8c5mdk.fsf@nosuchdomain.example.com> <ur08li$20k5b$2@dont-email.me>
<ur08rh$20k5b$3@dont-email.me> <ur0e3l$22db2$1@dont-email.me>
<ur0jq4$23h4i$1@dont-email.me> <ur0tgq$25adf$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Tue, 20 Feb 2024 01:03:29 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="b0f115137019fdce9f45de952e44b79b";
logging-data="2271663"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18pOH/fN8ieL1XQVpuVc71WYyBIBlKL6SM="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:vS2k5qcS396RZBdVzWS/Vqo50Kc=
Content-Language: en-GB
In-Reply-To: <ur0tgq$25adf$1@dont-email.me>
 by: Thiago Adams - Tue, 20 Feb 2024 01:03 UTC

Em 2/19/2024 9:59 PM, Thiago Adams escreveu:
....
> for this reason, source code should be standardised to be UTF8. (I guess
> C++ has a proposal for that)
>

https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2022/p2295r6.pdf

Re: strong types in c - (safety samples)

<20240219184507.140@kylheku.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=33558&group=comp.lang.c#33558

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: 433-929-...@kylheku.com (Kaz Kylheku)
Newsgroups: comp.lang.c
Subject: Re: strong types in c - (safety samples)
Date: Tue, 20 Feb 2024 02:48:24 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 23
Message-ID: <20240219184507.140@kylheku.com>
References: <uqb741$13gk8$1@dont-email.me> <ur067b$20k5b$1@dont-email.me>
<87bk8c5mdk.fsf@nosuchdomain.example.com> <ur08li$20k5b$2@dont-email.me>
<ur08rh$20k5b$3@dont-email.me> <ur0e3l$22db2$1@dont-email.me>
<ur0jq4$23h4i$1@dont-email.me>
Injection-Date: Tue, 20 Feb 2024 02:48:24 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="3ab2e551e8ae33ebc6759ce27449afd3";
logging-data="2427450"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+ONaeW3JRh3SMcBfmNAijGlZyKAVFcv4A="
User-Agent: slrn/pre1.0.4-9 (Linux)
Cancel-Lock: sha1:rQNP+zc1ki0uDb7f19aQJn7lXo4=
 by: Kaz Kylheku - Tue, 20 Feb 2024 02:48 UTC

On 2024-02-19, bart <bc@freeuk.com> wrote:
> I often use DATE and TIME in my products to help indicate version.
>
> It's not silly at all.
>
> But it means the binary produced will be slightly different to one
> generated 5 minutes earlier.

The problem is that it's possible that the only difference is the
date and time. In which case it's the same program. Just the binary is
gratuitously different.

Some GNU/Linux distros nowadays are obsessed with reproducibility:
meaning that whenver the same version of the same thing is built, all
the deliverables such as executables, PDF files or whatever else is bit
for bit identical to the previous runs.

This works even if if __DATE__ and __TIME__ are used; those get frozen.

--
TXR Programming Language: http://nongnu.org/txr
Cygnal: Cygwin Native Application Library: http://kylheku.com/cygnal
Mastodon: @Kazinator@mstdn.ca

Re: strong types in c - (safety samples)

<ur1cj1$2bi3o$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=33560&group=comp.lang.c#33560

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: chris.m....@gmail.com (Chris M. Thomasson)
Newsgroups: comp.lang.c
Subject: Re: strong types in c - (safety samples)
Date: Mon, 19 Feb 2024 21:16:16 -0800
Organization: A noiseless patient Spider
Lines: 22
Message-ID: <ur1cj1$2bi3o$1@dont-email.me>
References: <uqb741$13gk8$1@dont-email.me> <uqb80h$13jjj$1@dont-email.me>
<uqtceu$1bc6c$1@dont-email.me> <87cyst76lw.fsf@nosuchdomain.example.com>
<uqveco$1rfru$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Tue, 20 Feb 2024 05:16:17 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="179eda77360736dadd068492fcb3f96b";
logging-data="2476152"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18sKTQdBte3QcLVO7/WyFpTDreY3/v7+2E="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:PJXsLonIyyGRu0noIXdgcUoeZPg=
Content-Language: en-US
In-Reply-To: <uqveco$1rfru$1@dont-email.me>
 by: Chris M. Thomasson - Tue, 20 Feb 2024 05:16 UTC

On 2/19/2024 3:34 AM, Thiago Adams wrote:
> On 18/02/2024 19:25, Keith Thompson wrote:
>> Thiago Adams <thiago.adams@gmail.com> writes:
>> [...]
>>> In MISRA the concept is called "essential type"
>>>
>>> a == b
>>>
>>> The essential type of this expression is boolean.
>>
>> I don't have access to the MISRA guidelines (they're not free),
>> but if that's what they say, it sounds like they're badly written.
>
> Searching for MISRA "essential type" we can find something.
>
> For instance:
>
> https://stackoverflow.com/questions/44131637/misra-c-2012-rule-10-1-boolean-operand-to-be-used-in-case-where-expression-is-of
>
>

https://www.stroustrup.com/JSF-AV-rules.pdf

Re: strong types in c - (safety samples)

<87ttm34ptm.fsf@nosuchdomain.example.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=33562&group=comp.lang.c#33562

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Keith.S....@gmail.com (Keith Thompson)
Newsgroups: comp.lang.c
Subject: Re: strong types in c - (safety samples)
Date: Mon, 19 Feb 2024 22:23:01 -0800
Organization: None to speak of
Lines: 26
Message-ID: <87ttm34ptm.fsf@nosuchdomain.example.com>
References: <uqb741$13gk8$1@dont-email.me> <uqb80h$13jjj$1@dont-email.me>
<uqtceu$1bc6c$1@dont-email.me>
<87cyst76lw.fsf@nosuchdomain.example.com>
<uqveco$1rfru$1@dont-email.me> <ur1cj1$2bi3o$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain
Injection-Info: dont-email.me; posting-host="65843b3786512bc99ec54c23cf0b62cb";
logging-data="2497163"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19X/garFs2WiP8Gjo7LyCd7"
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux)
Cancel-Lock: sha1:1/pR7VDNTtz2C62apMbXo9sQdgg=
sha1:qv3bZ3E/RLnjvx7GD4EmaJ+rvGU=
 by: Keith Thompson - Tue, 20 Feb 2024 06:23 UTC

"Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> writes:
> On 2/19/2024 3:34 AM, Thiago Adams wrote:
>> On 18/02/2024 19:25, Keith Thompson wrote:
>>> Thiago Adams <thiago.adams@gmail.com> writes:
>>> [...]
>>>> In MISRA the concept is called "essential type"
>>>>
>>>> a == b
>>>>
>>>> The essential type of this expression is boolean.
>>>
>>> I don't have access to the MISRA guidelines (they're not free),
>>> but if that's what they say, it sounds like they're badly written.
>> Searching for MISRA "essential type" we can find something.
>> For instance:
>> https://stackoverflow.com/questions/44131637/misra-c-2012-rule-10-1-boolean-operand-to-be-used-in-case-where-expression-is-of
>
> https://www.stroustrup.com/JSF-AV-rules.pdf

Can you clarify the relevance? It doesn't say much about bool or
booleans and doesn't mention "essential type" at all.

--
Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com
Working, but not speaking, for Medtronic
void Void(void) { Void(); } /* The recursive call of the void */

Re: strong types in c - (safety samples)

<ur1oc7$2d9lc$4@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=33570&group=comp.lang.c#33570

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!feeder8.news.weretis.net!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: david.br...@hesbynett.no (David Brown)
Newsgroups: comp.lang.c
Subject: Re: strong types in c - (safety samples)
Date: Tue, 20 Feb 2024 09:37:27 +0100
Organization: A noiseless patient Spider
Lines: 42
Message-ID: <ur1oc7$2d9lc$4@dont-email.me>
References: <uqb741$13gk8$1@dont-email.me> <ur067b$20k5b$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Tue, 20 Feb 2024 08:37:27 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="cd656c5b12ef6e4d59946a4c8ecfc47e";
logging-data="2533036"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18nSfq75xgJao8V3F20J8v/lN8ExliD+II="
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101
Thunderbird/102.11.0
Cancel-Lock: sha1:AjoIwhZFcNobwfV2rBTETOhEE2k=
Content-Language: en-GB
In-Reply-To: <ur067b$20k5b$1@dont-email.me>
 by: David Brown - Tue, 20 Feb 2024 08:37 UTC

On 19/02/2024 19:21, Thiago Adams wrote:
> On 11/02/2024 16:27, Thiago Adams wrote:
>> Consider:
>>
>> void f(int i);
>>
>> enum E {A};
>>
>> int main(){
>>      f(A); //cake will have a warning here
>> }
>>
>>
>> I will create a diagnostic in cake for this and others.
>> Basically I will respect the standard where it says enumerators are
>> int, but I will create a strict mode where this and other types of
>> conversion happens.
>
> It is interesting to note that treating warnings as errors is not
> something new.
>
>
> "The initial ISO C standard and its 1999 revision removed support for
> many C language features that were widely known as sources of
> application bugs due to accidental misuse. For backwards compatibility,
> GCC 13 and earlier diagnosed use of these features as warnings only.
> Although these warnings have been enabled by default for many releases,
> experience shows that these warnings are easily ignored, resulting in
> difficult to diagnose bugs. In GCC 14, these issues are now reported as
> errors, and no output file is created, providing clearer feedback to
> programmers that something is wrong. "
>
> https://gcc.gnu.org/gcc-14/porting_to.html#c
>
>

This refers to a small number of specific warnings, not warnings in
general, and it /is/ new - gcc 14 is not yet released.

It's a good change, IMHO - and long overdue.

Re: strong types in c - (safety samples)

<ur1ons$2d9lc$5@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=33571&group=comp.lang.c#33571

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!feeder8.news.weretis.net!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: david.br...@hesbynett.no (David Brown)
Newsgroups: comp.lang.c
Subject: Re: strong types in c - (safety samples)
Date: Tue, 20 Feb 2024 09:43:40 +0100
Organization: A noiseless patient Spider
Lines: 50
Message-ID: <ur1ons$2d9lc$5@dont-email.me>
References: <uqb741$13gk8$1@dont-email.me> <ur067b$20k5b$1@dont-email.me>
<87bk8c5mdk.fsf@nosuchdomain.example.com> <ur08li$20k5b$2@dont-email.me>
<ur08rh$20k5b$3@dont-email.me> <ur0e3l$22db2$1@dont-email.me>
<ur0jq4$23h4i$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Tue, 20 Feb 2024 08:43:40 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="cd656c5b12ef6e4d59946a4c8ecfc47e";
logging-data="2533036"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX185JQGUjXK/eRg0G5gdUdznNk23/5mzt+s="
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101
Thunderbird/102.11.0
Cancel-Lock: sha1:AE77GeZYhpnEJ/TykI7jWMlGg+w=
In-Reply-To: <ur0jq4$23h4i$1@dont-email.me>
Content-Language: en-GB
 by: David Brown - Tue, 20 Feb 2024 08:43 UTC

On 19/02/2024 23:13, bart wrote:
> On 19/02/2024 20:36, David Brown wrote:
>> On 19/02/2024 20:06, Thiago Adams wrote:
>>>
>>> Something related
>>>
>>> https://embeddedartistry.com/blog/2017/05/22/werror-is-not-your-friend/
>>>
>>> "Different vendors have different warning sets and warning detection
>>> logic, even if they support a common array of warning settings (such
>>> as with GCC and Clang). Code that compiles with one toolchain
>>> warning-free may not do so with another toolchain. We often see this
>>> with our open-source projects. We primarily use Clang, and it is a
>>> common occurrence that our CI server will report a warning when
>>> compiling our “warning-free” code with GCC."
>>>
>>> Safety is not portable.
>>>
>>
>>
>> The blog's reasoning is flawed.
>>
>> A project build is dependent on three main things.  The source code is
>> one.  The toolchain is another.  And the build instructions -
>> including toolchain flags and options, linker scripts, and perhaps
>> things like the order of files passed to the linker.  (It may also
>> depend on things like the time and day, if you use macros like
>> __DATE__ and __TIME__, which is an extraordinarily silly thing to have
>> as a dependency.)
>
> I often use DATE and TIME in my products to help indicate version.
>
> It's not silly at all.
>
> But it means the binary produced will be slightly different to one
> generated 5 minutes earlier.
>

It is definitely a silly thing to do if you are looking for tight
control of your builds - precisely because it means your binaries differ
on different builds. When you are running a more sophisticated
development setup - such as one where CI is appropriate - reproducible
builds are important. __DATE__ and __TIME__ guarantee that you can't do
that.

Not all development has to be with such builds, of course, and __DATE__
and __TIME__ can be helpful if you are going through a lot of changes
quickly and want to compare runs. But it means you can never go back to
your previous source and get exactly the same binary.

Re: strong types in c - (safety samples)

<ur7d1p$3rsaq$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=33662&group=comp.lang.c#33662

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!usenet.goja.nl.eu.org!weretis.net!feeder8.news.weretis.net!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: janis_pa...@hotmail.com (Janis Papanagnou)
Newsgroups: comp.lang.c
Subject: Re: strong types in c - (safety samples)
Date: Thu, 22 Feb 2024 13:00:56 +0100
Organization: A noiseless patient Spider
Lines: 35
Message-ID: <ur7d1p$3rsaq$1@dont-email.me>
References: <uqb741$13gk8$1@dont-email.me> <ur067b$20k5b$1@dont-email.me>
<87bk8c5mdk.fsf@nosuchdomain.example.com> <ur08li$20k5b$2@dont-email.me>
<ur08rh$20k5b$3@dont-email.me> <ur0e3l$22db2$1@dont-email.me>
<ur0jq4$23h4i$1@dont-email.me> <20240219184507.140@kylheku.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=windows-1252
Content-Transfer-Encoding: 7bit
Injection-Date: Thu, 22 Feb 2024 12:00:57 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="90747243d2c7ad0519d7d8b17156f7ba";
logging-data="4059482"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18xneJaNJGw907Ju6o9Tygb"
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101
Thunderbird/45.8.0
Cancel-Lock: sha1:95FQ00UAjONBsOT2q3QhwZ3udmc=
X-Enigmail-Draft-Status: N1110
In-Reply-To: <20240219184507.140@kylheku.com>
 by: Janis Papanagnou - Thu, 22 Feb 2024 12:00 UTC

On 20.02.2024 03:48, Kaz Kylheku wrote:
> On 2024-02-19, bart <bc@freeuk.com> wrote:
>> I often use DATE and TIME in my products to help indicate version.
>> It's not silly at all.
>> But it means the binary produced will be slightly different to one
>> generated 5 minutes earlier.

I recall our configuration management and version control systems
supported variables for release information[*] that got expanded by
the system as part of the defined software development processes...

>
> The problem is that it's possible that the only difference is the
> date and time. In which case it's the same program. Just the binary is
> gratuitously different.

....and it was a project's decision whether this information had an
accuracy of check-in level ("patch-level"), or minor release level,
or anything else. So binaries could vary in that attribute or not.

>
> Some GNU/Linux distros nowadays are obsessed with reproducibility:
> meaning that whenver the same version of the same thing is built, all
> the deliverables such as executables, PDF files or whatever else is bit
> for bit identical to the previous runs.
>
> This works even if if __DATE__ and __TIME__ are used; those get frozen.

Janis

[*] So there was no need to have an own mechanism for every language
or every type of source! - I don't think it's a good idea to have
for every type of item its own distinct and inconsistent mechanism
and format defined to support version and/or time/date information.

Re: strong types in c - (safety samples)

<ur80s3$677$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=33668&group=comp.lang.c#33668

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: thiago.a...@gmail.com (Thiago Adams)
Newsgroups: comp.lang.c
Subject: Re: strong types in c - (safety samples)
Date: Thu, 22 Feb 2024 14:39:15 -0300
Organization: A noiseless patient Spider
Lines: 77
Message-ID: <ur80s3$677$1@dont-email.me>
References: <uqb741$13gk8$1@dont-email.me> <ur067b$20k5b$1@dont-email.me>
<87bk8c5mdk.fsf@nosuchdomain.example.com> <ur08li$20k5b$2@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Thu, 22 Feb 2024 17:39:15 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="ff86df76cb21dccf147e9f221f382e2e";
logging-data="6375"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+GWoFifF6xJbeF7ZF72SmyXEruKf2T19Y="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:xyAXp3HcJ/PGipmeb0wfGks0Kxw=
In-Reply-To: <ur08li$20k5b$2@dont-email.me>
Content-Language: en-US
 by: Thiago Adams - Thu, 22 Feb 2024 17:39 UTC

On 19/02/2024 16:03, Thiago Adams wrote:
> On 19/02/2024 15:39, Keith Thompson wrote:
>> Thiago Adams <thiago.adams@gmail.com> writes:
>>> On 11/02/2024 16:27, Thiago Adams wrote:
>>>> Consider:
>>>> void f(int i);
>>>> enum E {A};
>>>> int main(){
>>>>       f(A); //cake will have a warning here
>>>> }
>>>>
>>>> I will create a diagnostic in cake for this and others.
>>>> Basically I will respect the standard where it says enumerators are
>>>> int, but I will create a strict mode where this and other types of
>>>> conversion happens.
>>>
>>> It is interesting to note that treating warnings as errors is not
>>> something new.
>>>
>>>
>>> "The initial ISO C standard and its 1999 revision removed support for
>>> many C language features that were widely known as sources of
>>> application bugs due to accidental misuse. For backwards
>>> compatibility, GCC 13 and earlier diagnosed use of these features as
>>> warnings only. Although these warnings have been enabled by default
>>> for many releases, experience shows that these warnings are easily
>>> ignored, resulting in difficult to diagnose bugs. In GCC 14, these
>>> issues are now reported as errors, and no output file is created,
>>> providing clearer feedback to programmers that something is wrong. "
>>>
>>> https://gcc.gnu.org/gcc-14/porting_to.html#c
>>
>> I wouldn't call that "treating warnings as errors".  I'd call it "no
>> longer treating errors[*] as mere warnings".
>>
>> [*] The C standard never requires anything other than a #error directive
>> as a fatal error, but it does define constraints and syntax rules,
>> violations of which require a diagnostic.  gcc has traditionally treated
>> certain violations as non-fatal errors by default.  With gcc 14 (not yet
>> released), they're apparently changing at least some of these from
>> warnings to fatal errors (which IMHO they should have been already).
>>
>
> The interesting part is that it stop compilation. In this aspect the new
> compiler is assuming a safer approach.
>
> The other approach could be settings then if someone wants to update the
> compiler and keeps the old code compiler it is just a matter of changing
> settings. But new compiler has new defaults.
>
>
>

I did an experiment where is possible to create "sets" of warnings.

#define SAFE_REGION \
_Pragma("GCC diagnostic push") \
_Pragma("GCC diagnostic error \"-Wenum-compare\"")\
_Pragma("GCC diagnostic error \"-Wparentheses\"")\
_Pragma("GCC diagnostic error \"-Wuninitialized\"")

#define RESTORE \
_Pragma("GCC diagnostic pop")

enum E1 { A };
enum E2 { B };

SAFE_REGION
int main() {
int a, b;
if (a = b){}
if (A == B){}
} RESTORE

Pages:12
server_pubkey.txt

rocksolid light 0.9.8
clearnet tor