Rocksolid Light

Welcome to Rocksolid Light

mail  files  register  newsreader  groups  login

Message-ID:  

Recursion is the root of computation since it trades description for time.


devel / comp.lang.c / 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
strong types in c - (safety samples)

<uqb741$13gk8$1@dont-email.me>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=50798&group=comp.lang.c#50798

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!rocksolid2!news.neodome.net!news.mixmin.net!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: thiago.adams@gmail.com (Thiago Adams)
Newsgroups: comp.lang.c
Subject: strong types in c - (safety samples)
Date: Sun, 11 Feb 2024 16:27:56 -0300
Organization: A noiseless patient Spider
Lines: 23
Message-ID: <uqb741$13gk8$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Sun, 11 Feb 2024 19:28:01 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="9c992eea70c41794897bb66e9f874123";
logging-data="1163912"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18nx07IBQv1kslD0vM/loSeZfhtQIknXn4="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:nhmA0meE3Y0C4CeQGZVW4EbGN58=
Content-Language: en-GB
 by: Thiago Adams - Sun, 11 Feb 2024 19:27 UTC

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.

int main(){
f(true); //cake will have a warning here
f('A'); //not sure this one..
}

the same for enums.

Re: strong types in c - (safety samples)

<uqb80h$13jjj$1@dont-email.me>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=50799&group=comp.lang.c#50799

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!usenet.network!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: thiago.adams@gmail.com (Thiago Adams)
Newsgroups: comp.lang.c
Subject: Re: strong types in c - (safety samples)
Date: Sun, 11 Feb 2024 16:43:12 -0300
Organization: A noiseless patient Spider
Lines: 37
Message-ID: <uqb80h$13jjj$1@dont-email.me>
References: <uqb741$13gk8$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Sun, 11 Feb 2024 19:43:13 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="9c992eea70c41794897bb66e9f874123";
logging-data="1166963"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18TR98E+YGFdvvj8CrouQ0ffRzq0o1mY7A="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:IQs+ZbYK5uhVI7No3iUA+dCvOFQ=
Content-Language: en-GB
In-Reply-To: <uqb741$13gk8$1@dont-email.me>
 by: Thiago Adams - Sun, 11 Feb 2024 19:43 UTC

Em 2/11/2024 4:27 PM, Thiago Adams escreveu:
> 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.
>
>
> int main(){
>     f(true); //cake will have a warning here
>     f('A'); //not sure this one..
> }
>
> the same for enums.

This is also part of "is C prepared to be safer language"?
This can breaks code, or it can be a diagnostic..
If it breaks code it needs to work as "warning profile" where
programmers can opt in or out.

With "warning profiles" the new semantics can be added without breaking
compatibility.

Re: strong types in c - (safety samples)

<20240211123503.379@kylheku.com>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=50800&group=comp.lang.c#50800

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!news.niel.me!news.gegeweb.eu!gegeweb.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: 433-929-6894@kylheku.com (Kaz Kylheku)
Newsgroups: comp.lang.c
Subject: Re: strong types in c - (safety samples)
Date: Sun, 11 Feb 2024 20:37:04 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 22
Message-ID: <20240211123503.379@kylheku.com>
References: <uqb741$13gk8$1@dont-email.me>
Injection-Date: Sun, 11 Feb 2024 20:37:04 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="00a9f2e9b63e24c156cd63276b33d69c";
logging-data="1185400"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19JkO8U2j7hv6vVN5hXcmXshVK4EHf1ugY="
User-Agent: slrn/pre1.0.4-9 (Linux)
Cancel-Lock: sha1:KlEoThFCbg8c8gyQqz4tGVTXjus=
 by: Kaz Kylheku - Sun, 11 Feb 2024 20:37 UTC

On 2024-02-11, Thiago Adams <thiago.adams@gmail.com> wrote:
> Consider:
>
> void f(int i);
>
> enum E {A};
>
> int main(){
> f(A); //cake will have a warning here
> }

Why bother with enums that are stronger than in C++.

Mainly, you don't want this:

void f(enum E);
f(42);

--
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)

<uqbdlh$14k78$1@dont-email.me>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=50802&group=comp.lang.c#50802

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: thiago.adams@gmail.com (Thiago Adams)
Newsgroups: comp.lang.c
Subject: Re: strong types in c - (safety samples)
Date: Sun, 11 Feb 2024 18:19:44 -0300
Organization: A noiseless patient Spider
Lines: 42
Message-ID: <uqbdlh$14k78$1@dont-email.me>
References: <uqb741$13gk8$1@dont-email.me> <20240211123503.379@kylheku.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Sun, 11 Feb 2024 21:19:45 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="9c992eea70c41794897bb66e9f874123";
logging-data="1200360"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19kJ+KQygaUUKjfkcxipGK/bH78UxIqxd0="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:RzTq1H3FnU7DuIOvTv4qng9mPWI=
In-Reply-To: <20240211123503.379@kylheku.com>
Content-Language: en-GB
 by: Thiago Adams - Sun, 11 Feb 2024 21:19 UTC

Em 2/11/2024 5:37 PM, Kaz Kylheku escreveu:
> On 2024-02-11, Thiago Adams <thiago.adams@gmail.com> wrote:
>> Consider:
>>
>> void f(int i);
>>
>> enum E {A};
>>
>> int main(){
>> f(A); //cake will have a warning here
>> }
>
> Why bother with enums that are stronger than in C++.
>
> Mainly, you don't want this:
>
> void f(enum E);
> f(42);
>

In C++ this also compiles without errors.

https://godbolt.org/z/fYz4zqY3Y

(not sure if I understood you)

and

enum E {A};
void f(enum E e);

int main(){
f(1);
}

it an error in c++.
none in C

https://godbolt.org/z/7fqnv47dM

Re: strong types in c - (safety samples)

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

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=50805&group=comp.lang.c#50805

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!news.furie.org.uk!nntp.terraraq.uk!news.gegeweb.eu!gegeweb.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Keith.S.Thompson+u@gmail.com (Keith Thompson)
Newsgroups: comp.lang.c
Subject: Re: strong types in c - (safety samples)
Date: Sun, 11 Feb 2024 14:08:53 -0800
Organization: None to speak of
Lines: 31
Message-ID: <87jznaac22.fsf@nosuchdomain.example.com>
References: <uqb741$13gk8$1@dont-email.me> <20240211123503.379@kylheku.com>
<uqbdlh$14k78$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain
Injection-Info: dont-email.me; posting-host="a3ea5551d1916ca86f611a52355c117b";
logging-data="1215445"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX196eLbeLiX7R9MFDaIG6Ip0"
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux)
Cancel-Lock: sha1:NWRHoqZ1PaeoPnDwtM02ZAhn280=
sha1:mRk2NX5WW09SaCiMBoojJCcJqQQ=
 by: Keith Thompson - Sun, 11 Feb 2024 22:08 UTC

Thiago Adams <thiago.adams@gmail.com> writes:
> Em 2/11/2024 5:37 PM, Kaz Kylheku escreveu:
>> On 2024-02-11, Thiago Adams <thiago.adams@gmail.com> wrote:
>>> Consider:
>>>
>>> void f(int i);
>>>
>>> enum E {A};
>>>
>>> int main(){
>>> f(A); //cake will have a warning here
>>> }
>> Why bother with enums that are stronger than in C++.
>> Mainly, you don't want this:
>> void f(enum E);
>> f(42);
>>
>
> In C++ this also compiles without errors.
>
> https://godbolt.org/z/fYz4zqY3Y
>
> (not sure if I understood you)

C++ has both C-style enums and "enum class" types, that have stricter
type checking (fewer implicit conversions).

--
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)

<867cja47qp.fsf@linuxsc.com>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=50820&group=comp.lang.c#50820

  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: tr.17687@z991.linuxsc.com (Tim Rentsch)
Newsgroups: comp.lang.c
Subject: Re: strong types in c - (safety samples)
Date: Sun, 11 Feb 2024 20:38:38 -0800
Organization: A noiseless patient Spider
Lines: 29
Message-ID: <867cja47qp.fsf@linuxsc.com>
References: <uqb741$13gk8$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Injection-Info: dont-email.me; posting-host="354d2f36c9690da15a8ae0972e0ffebc";
logging-data="1444547"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/YL8tZ4nlC4nO6wUb7vKxGX5oSstJH5gA="
User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.4 (gnu/linux)
Cancel-Lock: sha1:ZeTHNFx6eM7FGYtpWFo8GLcr00U=
sha1:P9xY4AaNJZEzAkTEiACYIWPxaPo=
 by: Tim Rentsch - Mon, 12 Feb 2024 04:38 UTC

Thiago Adams <thiago.adams@gmail.com> writes:

> 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.
>
>
> int main(){
> f(true); //cake will have a warning here
> f('A'); //not sure this one..
> }
>
> the same for enums.

This is comp.lang.c. Please take any discussions of languages
other than C to a venue where those discussions are topical,
such as comp.lang.misc.

Re: strong types in c - (safety samples)

<uqc7v6$1c4fp$1@dont-email.me>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=50822&group=comp.lang.c#50822

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!rocksolid2!news.neodome.net!news.mixmin.net!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: thiago.adams@gmail.com (Thiago Adams)
Newsgroups: comp.lang.c
Subject: Re: strong types in c - (safety samples)
Date: Mon, 12 Feb 2024 01:48:37 -0300
Organization: A noiseless patient Spider
Lines: 45
Message-ID: <uqc7v6$1c4fp$1@dont-email.me>
References: <uqb741$13gk8$1@dont-email.me> <867cja47qp.fsf@linuxsc.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Mon, 12 Feb 2024 04:48:38 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="0fdb2e3a634e10568940305ab09526a7";
logging-data="1446393"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19xYG9NmXaxAPSpJUwYkzCSK7CSvY4Z/z8="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:lFRA8R9BHxecNP+6Iyc0sBpvSns=
In-Reply-To: <867cja47qp.fsf@linuxsc.com>
Content-Language: en-GB
 by: Thiago Adams - Mon, 12 Feb 2024 04:48 UTC

Em 2/12/2024 1:38 AM, Tim Rentsch escreveu:
> Thiago Adams <thiago.adams@gmail.com> writes:
>
>> 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.
>>
>>
>> int main(){
>> f(true); //cake will have a warning here
>> f('A'); //not sure this one..
>> }
>>
>> the same for enums.
>
> This is comp.lang.c. Please take any discussions of languages
> other than C to a venue where those discussions are topical,
> such as comp.lang.misc.

Not sure what you mean.
This is about C and diagnostics.

For instance:

void f(int i);
int main()
{ f(true);
}

If a compiler emit a diagnostic "warning passing _Bool to integer" do
you think this is not C any more?

Re: strong types in c - (safety samples)

<pan$95126$8bcf3268$1a2493f3$79009088@invalid.invalid>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=50842&group=comp.lang.c#50842

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!news.hispagatos.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!bluemanedhawk.eternal-september.org!.POSTED!not-for-mail
From: bluemanedhawk@invalid.invalid (Blue-Maned_Hawk)
Newsgroups: comp.lang.c
Subject: Re: strong types in c - (safety samples)
Date: Tue, 13 Feb 2024 07:58:58 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 13
Message-ID: <pan$95126$8bcf3268$1a2493f3$79009088@invalid.invalid>
References: <uqb741$13gk8$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Injection-Date: Tue, 13 Feb 2024 07:58:58 -0000 (UTC)
Injection-Info: bluemanedhawk.eternal-september.org; posting-host="11698f522d91f0e08ce21e379a4da35f";
logging-data="2096770"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18razPfAoZzqeaRsdnkbeBceRn3MjK8gs4="
User-Agent: Pan/0.154 (Izium; 517acf4)
Cancel-Lock: sha1:ORSzQgtFpLXITsF1KdM0wbmrAqI=
Face: iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAIAAADYYG7QAAACh0lEQVRYw71Z21bD
MAzzevbfkr4cHjrSXJyL044+MDa6WLEl2SkvkrZ1AbAvXO+bUGSCPYnsuIVGMpm
ZLnjX718GhAKNsp8lON2F9VrhELwIgJlBepkZjA78rVK+FkmNhEJK76UsJlz8+E
rJsjrpYouhLo/SC6qPHgakFOR8wV9+8rCfO/I/oVnmUZUp42/LW2XkLj9TCFNM9
jp5g2EmHZgpYZjCOkYU7sXVogRylJqpdggoFLG1g09Flah/7kErCxzR9HgXPYsq
0glb9cxjIz2Vsk9AmAoCSxECpD713joMKjQqLAtmMqJmXjdVvlMnMQCVITotJd1
z+fh1f1NNo+vuc1KnhWUmY7t03vydTud9BbXCtN3L2PL3bK7JCNG0GHzuZxafyB
fxevCxpm1vrwZltqw6SILCcdoCE6PGQC8wZWDA9Or7Qp5s3lAZezys0nDazs9S9
R0TjwEiksRxLkNPC1NMMWPs1bj0Ei0Yuo+JVtFLuzP1NRJ16qXWN8DhhtmS4PDg
O6mqRxs4bEJrYt087mSIow/1VzW2oFlMQuiuIy/KsUagvhdw6hSjJGlIavbLF8x
j3X47bccLcUSi0dkWh1nUZNhANT1tHKUXrNxNLbd9KPb9wDDVrKwmPQMOPQ1oy6
k5I1DwzDeRJd3jVIhDAUxq3ngzJG4CCkNXZxZVMcjefoK2J0gUY2S3rxz/RuTFx
2zHd9U+obimJXMG4edsk/2j5pTU5G1MmzbRLxkfq5EiT1GGsidvMGzi+1goGb2l
GCrN+nGnV8xj3q3JLRDVPL96vUc7Z4aJ3TN1mVqWAMJMfG+Jxh6TQqP+92iZkCU
xtglds1AB6r0aiSHKcnFck+p/c/0CbacFLQcajGcAAAAASUVORK5CYII=
X-Face: Llanfair­pwllgwyng
yll
­gogeryÂÃ
? ?­chwyrnÂÂÂÂÂÂ
­drobwll­llanÃ
‚Ã
ƒƒƒ‚­tysilioÂÂÂÃ
‚­gogo­goch
 by: Blue-Maned_Hawk - Tue, 13 Feb 2024 07:58 UTC

Clang has an existing system for this with its
[[clang::enum_extensibility(open)]] and
[[clang::enum_extensibility(closed)]] attributes.

--
Blue-Maned_Hawk│shortens to
Hawk│/
blu.mɛin.dÊ°ak/
│he/him/his/himself/Mr.
blue-maned_hawk.srht.site
Looks like it could explode at any moment!

Re: strong types in c - (safety samples)

<uqfbjo$2123l$1@dont-email.me>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=50844&group=comp.lang.c#50844

  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: malcolm.arthur.mclean@gmail.com (Malcolm McLean)
Newsgroups: comp.lang.c
Subject: Re: strong types in c - (safety samples)
Date: Tue, 13 Feb 2024 09:09:12 +0000
Organization: A noiseless patient Spider
Lines: 29
Message-ID: <uqfbjo$2123l$1@dont-email.me>
References: <uqb741$13gk8$1@dont-email.me> <20240211123503.379@kylheku.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Tue, 13 Feb 2024 09:09:12 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="e7a5a25b3c21747ffff050cc2de5b7cd";
logging-data="2132085"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+ei46igJGlT2TV3rBLV0I8uYCX9aCVzzk="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:MUL9lCaXPJxNur7oAM568stjvXA=
Content-Language: en-GB
In-Reply-To: <20240211123503.379@kylheku.com>
 by: Malcolm McLean - Tue, 13 Feb 2024 09:09 UTC

On 11/02/2024 20:37, Kaz Kylheku wrote:
> On 2024-02-11, Thiago Adams <thiago.adams@gmail.com> wrote:
>> Consider:
>>
>> void f(int i);
>>
>> enum E {A};
>>
>> int main(){
>> f(A); //cake will have a warning here
>> }
>
> Why bother with enums that are stronger than in C++.
>
> Mainly, you don't want this:
>
> void f(enum E);
> f(42);
>
The problem is that enums often have to go through things which are
external to the program. For example they might be stored in a database
which is read by a parser which isn't written in C. So they can't be
treated as entirely opaque and sometimes you do need to manipulate the
values.

--
Check out Basic Algorithms and my other books:
https://www.lulu.com/spotlight/bgy1mm

Re: strong types in c - (safety samples)

<87r0hglat9.fsf@bsb.me.uk>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=50851&group=comp.lang.c#50851

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!rocksolid2!news.neodome.net!news.mixmin.net!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: ben.usenet@bsb.me.uk (Ben Bacarisse)
Newsgroups: comp.lang.c
Subject: Re: strong types in c - (safety samples)
Date: Tue, 13 Feb 2024 14:04:50 +0000
Organization: A noiseless patient Spider
Lines: 40
Message-ID: <87r0hglat9.fsf@bsb.me.uk>
References: <uqb741$13gk8$1@dont-email.me> <20240211123503.379@kylheku.com>
<uqfbjo$2123l$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain
Injection-Info: dont-email.me; posting-host="7afb96008295e9afd859ffb3bddfc990";
logging-data="2229708"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/wszBndXO2FuOCjOMycgk7+w6vrw5tVhE="
User-Agent: Gnus/5.13 (Gnus v5.13)
Cancel-Lock: sha1:eH59wO2c80VioBiW3CKyByn4Uyw=
sha1:9ZowRr4e22LyvsX4DZ/d0iNVNWg=
X-BSB-Auth: 1.c54828f517137905cd11.20240213140450GMT.87r0hglat9.fsf@bsb.me.uk
 by: Ben Bacarisse - Tue, 13 Feb 2024 14:04 UTC

Malcolm McLean <malcolm.arthur.mclean@gmail.com> writes:

> On 11/02/2024 20:37, Kaz Kylheku wrote:
>> On 2024-02-11, Thiago Adams <thiago.adams@gmail.com> wrote:
>>> Consider:
>>>
>>> void f(int i);
>>>
>>> enum E {A};
>>>
>>> int main(){
>>> f(A); //cake will have a warning here
>>> }
>> Why bother with enums that are stronger than in C++.
>> Mainly, you don't want this:
>> void f(enum E);
>> f(42);
>>
> The problem is that enums often have to go through things which are
> external to the program. For example they might be stored in a database
> which is read by a parser which isn't written in C.

That's "a problem" (though not usually a hard one) but it's not got
anything to do with the current discussion about how C does, or should,
limit the use of implicit type conversions for enums.

Typically, "the problem" would be solved by the build system. It would
ensure that the names and values in the DB match (or correspond to)
those used in the C program, probably by generating a header file and/or
a DB table as part of the build.

> So they can't be
> treated as entirely opaque and sometimes you do need to manipulate the
> values.

But no one is suggesting that. The discussion is about what implicit
type conversions are, or should, be allowed without any diagnostic.

--
Ben.

Re: strong types in c - (safety samples)

<86bk8gz8c8.fsf@linuxsc.com>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=51034&group=comp.lang.c#51034

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!rocksolid2!news.neodome.net!weretis.net!feeder8.news.weretis.net!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: tr.17687@z991.linuxsc.com (Tim Rentsch)
Newsgroups: comp.lang.c
Subject: Re: strong types in c - (safety samples)
Date: Fri, 16 Feb 2024 08:23:35 -0800
Organization: A noiseless patient Spider
Lines: 53
Message-ID: <86bk8gz8c8.fsf@linuxsc.com>
References: <uqb741$13gk8$1@dont-email.me> <867cja47qp.fsf@linuxsc.com> <uqc7v6$1c4fp$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Injection-Info: dont-email.me; posting-host="acda77ef139adc7a575507d0f435d89d";
logging-data="4131441"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+1oyHTHOUhEsN8dPwI953XGHw/Zc7uBi0="
User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.4 (gnu/linux)
Cancel-Lock: sha1:kPee3UgWvfx1YNvH/wYaA4ZM7UM=
sha1:7lkNOPnJKBgbww3hQHy0CdL4EGs=
 by: Tim Rentsch - Fri, 16 Feb 2024 16:23 UTC

Thiago Adams <thiago.adams@gmail.com> writes:

> Em 2/12/2024 1:38 AM, Tim Rentsch escreveu:
>
>> Thiago Adams <thiago.adams@gmail.com> writes:
>>
>>> 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.
>>>
>>>
>>> int main(){
>>> f(true); //cake will have a warning here
>>> f('A'); //not sure this one..
>>> }
>>>
>>> the same for enums.
>>
>> This is comp.lang.c. Please take any discussions of languages
>> other than C to a venue where those discussions are topical,
>> such as comp.lang.misc.
>
> Not sure what you mean.
> This is about C and diagnostics.
>
> For instance:
>
> void f(int i);
> int main()
> {
> f(true);
> }
>
> If a compiler emit a diagnostic "warning passing _Bool to integer" do
> you think this is not C any more?

The language you're talking about may have the same syntax
as C, but it has different semantic rules, and that is the
point of your discussion. What you're talking about is not
about C. I know you like to pretend that it's the same,
but it isn't.

Re: strong types in c - (safety samples)

<uqq8ol$d84e$1@dont-email.me>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=51067&group=comp.lang.c#51067

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!news.niel.me!news.gegeweb.eu!gegeweb.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: thiago.adams@gmail.com (Thiago Adams)
Newsgroups: comp.lang.c
Subject: Re: strong types in c - (safety samples)
Date: Sat, 17 Feb 2024 09:28:05 -0300
Organization: A noiseless patient Spider
Lines: 67
Message-ID: <uqq8ol$d84e$1@dont-email.me>
References: <uqb741$13gk8$1@dont-email.me> <867cja47qp.fsf@linuxsc.com>
<uqc7v6$1c4fp$1@dont-email.me> <86bk8gz8c8.fsf@linuxsc.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Sat, 17 Feb 2024 12:28:05 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="01e061066fdd40397526e3a24efb9ec7";
logging-data="434318"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18jovvfxITn5iR+0VQU6ndfB8ZLvrT2Vro="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:nGPc9AvKUobeYRdPdzbgMyDDtag=
Content-Language: en-GB
In-Reply-To: <86bk8gz8c8.fsf@linuxsc.com>
 by: Thiago Adams - Sat, 17 Feb 2024 12:28 UTC

Em 2/16/2024 1:23 PM, Tim Rentsch escreveu:
> Thiago Adams <thiago.adams@gmail.com> writes:
>
>> Em 2/12/2024 1:38 AM, Tim Rentsch escreveu:
>>
>>> Thiago Adams <thiago.adams@gmail.com> writes:
>>>
>>>> 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.
>>>>
>>>>
>>>> int main(){
>>>> f(true); //cake will have a warning here
>>>> f('A'); //not sure this one..
>>>> }
>>>>
>>>> the same for enums.
>>>
>>> This is comp.lang.c. Please take any discussions of languages
>>> other than C to a venue where those discussions are topical,
>>> such as comp.lang.misc.
>>
>> Not sure what you mean.
>> This is about C and diagnostics.
>>
>> For instance:
>>
>> void f(int i);
>> int main()
>> {
>> f(true);
>> }
>>
>> If a compiler emit a diagnostic "warning passing _Bool to integer" do
>> you think this is not C any more?
>
> The language you're talking about may have the same syntax
> as C, but it has different semantic rules, and that is the
> point of your discussion. What you're talking about is not
> about C. I know you like to pretend that it's the same,
> but it isn't.

Perhaps you got a bad first impression. However, Cake is indeed 100% C.
The modes I am discussing here have not been implemented yet. Even when
implemented, they are not fundamentally different from, for instance,
gcc's -werror option.

I am not pretending Cake is C. I am following the C23 standard and other
compilers like gcc, clang and msvc. Cake have some extensions, like any
other C compiler and the extensions are documented.

Re: strong types in c - (safety samples)

<uqtceu$1bc6c$1@dont-email.me>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=51149&group=comp.lang.c#51149

  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.adams@gmail.com (Thiago Adams)
Newsgroups: comp.lang.c
Subject: Re: strong types in c - (safety samples)
Date: Sun, 18 Feb 2024 13:49:33 -0300
Organization: A noiseless patient Spider
Lines: 30
Message-ID: <uqtceu$1bc6c$1@dont-email.me>
References: <uqb741$13gk8$1@dont-email.me> <uqb80h$13jjj$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Sun, 18 Feb 2024 16:49:34 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="30f1df4c5702a41a363ed00a1e1a95a0";
logging-data="1421516"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19oSQzze8IWVE4pxHyUYIlLFxEdDaJ8X/k="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:EOLyRDzoYNJAYm4xTD5FujkHuwU=
Content-Language: en-GB
In-Reply-To: <uqb80h$13jjj$1@dont-email.me>
 by: Thiago Adams - Sun, 18 Feb 2024 16:49 UTC

Em 2/11/2024 4:43 PM, Thiago Adams escreveu:
> Em 2/11/2024 4:27 PM, Thiago Adams escreveu:
>> 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.

In MISRA the concept is called "essential type"

a == b

The essential type of this expression is boolean.

Re: strong types in c - (safety samples)

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

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=51166&group=comp.lang.c#51166

  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.Thompson+u@gmail.com (Keith Thompson)
Newsgroups: comp.lang.c
Subject: Re: strong types in c - (safety samples)
Date: Sun, 18 Feb 2024 14:25:15 -0800
Organization: None to speak of
Lines: 38
Message-ID: <87cyst76lw.fsf@nosuchdomain.example.com>
References: <uqb741$13gk8$1@dont-email.me> <uqb80h$13jjj$1@dont-email.me>
<uqtceu$1bc6c$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit
Injection-Info: dont-email.me; posting-host="b18c3c7ac9146633dc598f0a8f97c261";
logging-data="1565976"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX191hGtpCxU/gNuKcL0i5dUX"
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux)
Cancel-Lock: sha1:AkpCvKP57Br+fkKduEgb30AVogY=
sha1:VAvm16qSDLD8R6ZiP89YShp+6RE=
 by: Keith Thompson - Sun, 18 Feb 2024 22:25 UTC

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.

(It's available for £15.00 from misra.org.uk. I'm almost, but not
quite, tempted to buy a copy.)

There's no C type called "boolean" unless you define it yourself.
The "essential type" they call "boolean" obviously isn't bool or
_Bool. It's not even a type in the C sense. And other posts here
have suggested that MISRA never actually defines what "essential
type" means.

Do the guidelines use the term "essential type" for "types" other
than "boolean"?

It just seems that the authors failed to think of the word
"condition", which would be a much clearer and more precise
description of what I presume they're trying to say. For example,
they could have written than any expression used as a condition
shall not be an assignment and shall not have an assignment as
any of its subexpressions, and anyone familiar with C would know
exactly what they mean. (The C standard doesn't define "condition",
but it would be easy to enumerate the contexts in which expressions
are treated as conditions, i.e., where a decision is made based on
whether the expression compares unequal to zero.)

--
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)

<uqu113$1frfr$1@dont-email.me>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=51171&group=comp.lang.c#51171

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!news.nntp4.net!news.hispagatos.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: david.brown@hesbynett.no (David Brown)
Newsgroups: comp.lang.c
Subject: Re: strong types in c - (safety samples)
Date: Sun, 18 Feb 2024 23:40:35 +0100
Organization: A noiseless patient Spider
Lines: 59
Message-ID: <uqu113$1frfr$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>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Sun, 18 Feb 2024 22:40:35 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="a67052fbca29f87f910ceb188b83db2e";
logging-data="1568251"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18c+O5AAAj78MvDuNh34FPwKsFpe6vuV4Q="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:eicvKG1SZ1nOPpblfIpFEdTP6DA=
In-Reply-To: <87cyst76lw.fsf@nosuchdomain.example.com>
Content-Language: en-GB
 by: David Brown - Sun, 18 Feb 2024 22:40 UTC

On 18/02/2024 23: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.

They were £10, last I bought a copy, so it's not /that/ expensive. But
IMHO the "essential type" stuff is not at all good.

>
> (It's available for £15.00 from misra.org.uk. I'm almost, but not
> quite, tempted to buy a copy.)

I'll probably buy a current version, because it is somewhat relevant to
my work. (Or I could get the office to buy it.)

>
> There's no C type called "boolean" unless you define it yourself.
> The "essential type" they call "boolean" obviously isn't bool or
> _Bool. It's not even a type in the C sense. And other posts here
> have suggested that MISRA never actually defines what "essential
> type" means.
>
> Do the guidelines use the term "essential type" for "types" other
> than "boolean"?

Oh, yes. They use it for lots of things, without good definitions,
without accurate consideration for things like integer promotion rules,
and in ways that somewhat differ from the actual C rules.

>
> It just seems that the authors failed to think of the word
> "condition", which would be a much clearer and more precise
> description of what I presume they're trying to say. For example,
> they could have written than any expression used as a condition
> shall not be an assignment and shall not have an assignment as
> any of its subexpressions, and anyone familiar with C would know
> exactly what they mean. (The C standard doesn't define "condition",
> but it would be easy to enumerate the contexts in which expressions
> are treated as conditions, i.e., where a decision is made based on
> whether the expression compares unequal to zero.)
>

They were trying to think of a way to say that things like the 0 or 1
int result of a comparison is not really the same thing as a normal
"int", and that the enumeration constants for an enumerated type are not
the same "essential type" as "int", and various other such things. They
are trying to invent their own type system that they think is better
than C's (and in some ways it /is/ better), and then say you should
write your C code as though it followed /their/ type system and not C's
type system.

Re: strong types in c - (safety samples)

<874je57518.fsf@nosuchdomain.example.com>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=51176&group=comp.lang.c#51176

  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.Thompson+u@gmail.com (Keith Thompson)
Newsgroups: comp.lang.c
Subject: Re: strong types in c - (safety samples)
Date: Sun, 18 Feb 2024 14:59:15 -0800
Organization: None to speak of
Lines: 22
Message-ID: <874je57518.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>
<uqu113$1frfr$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain
Injection-Info: dont-email.me; posting-host="b18c3c7ac9146633dc598f0a8f97c261";
logging-data="1572724"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/S/Mc2/aqu5aLqpoIJYM6y"
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux)
Cancel-Lock: sha1:GqYnxgIbU3GQybS3o0Qc2SOm47c=
sha1:wWBERxiBgbb9LFQWwUxIUKfvITc=
 by: Keith Thompson - Sun, 18 Feb 2024 22:59 UTC

David Brown <david.brown@hesbynett.no> writes:
[...]
> They were trying to think of a way to say that things like the 0 or 1
> int result of a comparison is not really the same thing as a normal
> "int", and that the enumeration constants for an enumerated type are
> not the same "essential type" as "int", and various other such things.
> They are trying to invent their own type system that they think is
> better than C's (and in some ways it /is/ better), and then say you
> should write your C code as though it followed /their/ type system and
> not C's type system.

And then they don't clearly define their own type system, or distinguish
C types from MISRA types.

I suspect it's easy enough to get through the vague wording and figure
out what the guidelines actually mean, but it sounds like the whole
thing would benefit from a rewrite.

--
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)

<uqveco$1rfru$1@dont-email.me>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=51209&group=comp.lang.c#51209

  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.adams@gmail.com (Thiago Adams)
Newsgroups: comp.lang.c
Subject: Re: strong types in c - (safety samples)
Date: Mon, 19 Feb 2024 08:34:50 -0300
Organization: A noiseless patient Spider
Lines: 19
Message-ID: <uqveco$1rfru$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>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Mon, 19 Feb 2024 11:34:48 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="631b19cabe631b451a98ecd9ed4e8f91";
logging-data="1949566"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+Zldam5K34n4My+IyZBmtM83cLFYowQS8="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:NilZcRGMt6SD5Lde0E+ZS7fTV4k=
Content-Language: en-US
In-Reply-To: <87cyst76lw.fsf@nosuchdomain.example.com>
 by: Thiago Adams - Mon, 19 Feb 2024 11:34 UTC

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

Re: strong types in c - (safety samples)

<ur067b$20k5b$1@dont-email.me>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=51229&group=comp.lang.c#51229

  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: thiago.adams@gmail.com (Thiago Adams)
Newsgroups: comp.lang.c
Subject: Re: strong types in c - (safety samples)
Date: Mon, 19 Feb 2024 15:21:31 -0300
Organization: A noiseless patient Spider
Lines: 34
Message-ID: <ur067b$20k5b$1@dont-email.me>
References: <uqb741$13gk8$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Mon, 19 Feb 2024 18:21:31 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="631b19cabe631b451a98ecd9ed4e8f91";
logging-data="2117803"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18IkJFTdYHtnuI8gAWSfDpoXq2mslqjCnA="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:gZWep5pZGWbfj1swide68HPsC6Y=
In-Reply-To: <uqb741$13gk8$1@dont-email.me>
Content-Language: en-US
 by: Thiago Adams - Mon, 19 Feb 2024 18:21 UTC

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

Re: strong types in c - (safety samples)

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

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=51231&group=comp.lang.c#51231

  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.Thompson+u@gmail.com (Keith Thompson)
Newsgroups: comp.lang.c
Subject: Re: strong types in c - (safety samples)
Date: Mon, 19 Feb 2024 10:39:51 -0800
Organization: None to speak of
Lines: 44
Message-ID: <87bk8c5mdk.fsf@nosuchdomain.example.com>
References: <uqb741$13gk8$1@dont-email.me> <ur067b$20k5b$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit
Injection-Info: dont-email.me; posting-host="3063e15dd79afee7d5be32a08e65d14a";
logging-data="2124939"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/zYvGe56Xe1qq9De+Wt8ZU"
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux)
Cancel-Lock: sha1:21WfsGAFGWL959dGwXglIuhPC9w=
sha1:RABXEu8qNhJtggSJNhl4ez3TqRI=
 by: Keith Thompson - Mon, 19 Feb 2024 18:39 UTC

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).

--
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)

<ur08li$20k5b$2@dont-email.me>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=51232&group=comp.lang.c#51232

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!news.samoylyk.net!weretis.net!feeder8.news.weretis.net!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: thiago.adams@gmail.com (Thiago Adams)
Newsgroups: comp.lang.c
Subject: Re: strong types in c - (safety samples)
Date: Mon, 19 Feb 2024 16:03:14 -0300
Organization: A noiseless patient Spider
Lines: 51
Message-ID: <ur08li$20k5b$2@dont-email.me>
References: <uqb741$13gk8$1@dont-email.me> <ur067b$20k5b$1@dont-email.me>
<87bk8c5mdk.fsf@nosuchdomain.example.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Mon, 19 Feb 2024 19:03:14 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="631b19cabe631b451a98ecd9ed4e8f91";
logging-data="2117803"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+fXFxhZxQ45KM/YmdUgc9aaL1l5/NLOFc="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:nbHKybptYPlJNXKQTVPyzriok4E=
Content-Language: en-US
In-Reply-To: <87bk8c5mdk.fsf@nosuchdomain.example.com>
 by: Thiago Adams - Mon, 19 Feb 2024 19:03 UTC

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.

Re: strong types in c - (safety samples)

<ur08rh$20k5b$3@dont-email.me>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=51233&group=comp.lang.c#51233

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!news.swapon.de!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: thiago.adams@gmail.com (Thiago Adams)
Newsgroups: comp.lang.c
Subject: Re: strong types in c - (safety samples)
Date: Mon, 19 Feb 2024 16:06:24 -0300
Organization: A noiseless patient Spider
Lines: 68
Message-ID: <ur08rh$20k5b$3@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: Mon, 19 Feb 2024 19:06:25 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="631b19cabe631b451a98ecd9ed4e8f91";
logging-data="2117803"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX198QVPPZp0wR+4dJIM8fZNKb0D6yufVC+c="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:YmDFcZBIYO0ePdV/KXtdLiYD/+M=
In-Reply-To: <ur08li$20k5b$2@dont-email.me>
Content-Language: en-US
 by: Thiago Adams - Mon, 19 Feb 2024 19:06 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.
>
>
>

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.

Re: strong types in c - (safety samples)

<877cj05jzs.fsf@nosuchdomain.example.com>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=51235&group=comp.lang.c#51235

  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.Thompson+u@gmail.com (Keith Thompson)
Newsgroups: comp.lang.c
Subject: Re: strong types in c - (safety samples)
Date: Mon, 19 Feb 2024 11:31:19 -0800
Organization: None to speak of
Lines: 77
Message-ID: <877cj05jzs.fsf@nosuchdomain.example.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>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit
Injection-Info: dont-email.me; posting-host="3063e15dd79afee7d5be32a08e65d14a";
logging-data="2147545"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18q9pGIYrm0gCFVtpcIzUqU"
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux)
Cancel-Lock: sha1:b3FH98lb6gFg9hTluLZ2lOhuppA=
sha1:PwuYgYe7N0ct1E4+l4SACHms5J4=
 by: Keith Thompson - Mon, 19 Feb 2024 19:31 UTC

Thiago Adams <thiago.adams@gmail.com> writes:
> 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.

Yes, that's pretty much what I said.

>> 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.
>
> 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 problem with -Werror is that it treats *all* warnings as fatal
errors. (Which an also be an advantage if you're aware of the issues).

But that's not directly related. The changes in gcc-14 have to do with
treating some constraint violations as fatal errors rather than warnings
by default. You can use -pedantic-errors to do the same thing.

--
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)

<ur0e3l$22db2$1@dont-email.me>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=51236&group=comp.lang.c#51236

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!news.hispagatos.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: david.brown@hesbynett.no (David Brown)
Newsgroups: comp.lang.c
Subject: Re: strong types in c - (safety samples)
Date: Mon, 19 Feb 2024 21:36:04 +0100
Organization: A noiseless patient Spider
Lines: 51
Message-ID: <ur0e3l$22db2$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>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Mon, 19 Feb 2024 20:36:05 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="f8441977aeb140d8df1ed75f541a5826";
logging-data="2176354"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/IIFUDy9E44vlQ1X7NCB4aVE7/fFN3XfI="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:nkHhmuF7DXZ6cn87B4tIb8NEogk=
Content-Language: en-GB
In-Reply-To: <ur08rh$20k5b$3@dont-email.me>
 by: David Brown - Mon, 19 Feb 2024 20:36 UTC

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.)

If you are making code that is important enough to be using CI tools,
and you have random mixtures of toolchains for different developers,
your CI server, and other parts of the system, then your development
process is badly broken. You are doing your CI and testing on a
different project from the one developers are working on, and the
projects being shipped to customers can be different again.

It can be a different matter if the deliverable for the project is just
the source code. But if it is a binary, then everything that goes into
the binary is part of the source for it, and needs to be kept under
tight control in the development process.

You might feel that it is useful to build multiple binaries using
different toolchains, perhaps to take advantage of static checks that
are available in a range of tools, or to ensure wider compatibility.
But then all those toolchains are part of the development process.

If you have not reached the stage of getting reproducible builds that
give the same binary every build for every developer, you are not ready
for tools like CI.

This is all IMHO, needless to say.

Re: strong types in c - (safety samples)

<ur0jq4$23h4i$1@dont-email.me>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=51237&group=comp.lang.c#51237

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!usenet.network!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: bc@freeuk.com (bart)
Newsgroups: comp.lang.c
Subject: Re: strong types in c - (safety samples)
Date: Mon, 19 Feb 2024 22:13:24 +0000
Organization: A noiseless patient Spider
Lines: 35
Message-ID: <ur0jq4$23h4i$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>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Mon, 19 Feb 2024 22:13:24 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="7ae817e3173231502c4282baf29220d3";
logging-data="2213010"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18d5Y9bFGPjDdqXMLTjVw43MyY+Z3EJj4o="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:D0MInGMw4HN6SkUitRCmOXh4KaU=
In-Reply-To: <ur0e3l$22db2$1@dont-email.me>
Content-Language: en-GB
 by: bart - Mon, 19 Feb 2024 22:13 UTC

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.

Re: strong types in c - (safety samples)

<ur0tgq$25adf$1@dont-email.me>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=51239&group=comp.lang.c#51239

  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.adams@gmail.com (Thiago Adams)
Newsgroups: comp.lang.c
Subject: Re: strong types in c - (safety samples)
Date: Mon, 19 Feb 2024 21:59:05 -0300
Organization: A noiseless patient Spider
Lines: 57
Message-ID: <ur0tgq$25adf$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>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Tue, 20 Feb 2024 00:59:06 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="b0f115137019fdce9f45de952e44b79b";
logging-data="2271663"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/fVNTKC9F22lLyzuqYOsQgjOeUddkxke4="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:hK9TLgv5L2TPVsDp2VRXAd1wpVs=
In-Reply-To: <ur0jq4$23h4i$1@dont-email.me>
Content-Language: en-GB
 by: Thiago Adams - Tue, 20 Feb 2024 00:59 UTC

Em 2/19/2024 7:13 PM, bart escreveu:
> 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.
>

I have a better sample

Consider the literal string

u8"maçã"

if the source code is not UTF8 encoded then the result of compilation
u8"maçã" will depend where (locale) the source code is compiled because
the compiler will encode the bytes from the file according with the
locale. This happens all the time with visual studio where the default
for new files is not utft8 (fortunately the compiler have a warning now,
but not default it needs to be added)

for this reason, source code should be standardised to be UTF8. (I guess
C++ has a proposal for that)

Pages:12
server_pubkey.txt

rocksolid light 0.9.81
clearnet tor