Re: how cast works?

Liste des GroupesRevenir à cl c  
Sujet : Re: how cast works?
De : tr.17687 (at) *nospam* z991.linuxsc.com (Tim Rentsch)
Groupes : comp.lang.c
Date : 03. Sep 2024, 15:02:20
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <865xrcq49v.fsf@linuxsc.com>
References : 1 2 3 4 5 6 7 8 9 10 11 12 13 14
User-Agent : Gnus/5.11 (Gnus v5.11) Emacs/22.4 (gnu/linux)
Keith Thompson <Keith.S.Thompson+u@gmail.com> writes:

Tim Rentsch <tr.17687@z991.linuxsc.com> writes:
>
Keith Thompson <Keith.S.Thompson+u@gmail.com> writes:
>
David Brown <david.brown@hesbynett.no> writes:
>
On 09/08/2024 01:14, Keith Thompson wrote:
>
David Brown <david.brown@hesbynett.no> writes:
[...]
>
A _Bool is always either 0 or 1.  The conversion is whatever
the compiler needs to give an int of value 0 or 1.
>
The value of a _Bool object is always either 0 or 1 *unless* the
program does something weird.
>
True.  But attempting to use a _Bool object (as a _Bool) that
does not contain either 0 or 1 is going to be undefined behaviour
(at least it was on the platform where I saw this happen as a
code bug).
>
It depends on whether representations with non-zero padding bits
are treated as trap representations (non-value representations in
C23) or not.
>
In C99 and C11, iirc, the width of _Bool may be any value between 1
and CHAR_BIT.  If the width of _Bool is greater than 1, a _Bool may
have a well-defined value that is neither 0 or 1.  My guess is most
implementations define the width of _Bool as 1, but they don't have
to (again, iirc, in C99 and C11).
>
C11 (N1570) isn't 100% clear, but I think you're right.  The
conversion rank of _Bool is less than the rank of the char types.
I don't see an explicit statement that this implies that _Bool has
less precision than unsigned char, [...]

C11 (and I think also C99, but I haven't checked that) states
requirements that guarantee _Bool has a width no larger than the
width of unsigned char.  I'm sure you can locate the relevant
passages.


It doesn't specify whether setting the padding bits to 1 results
in a non-value representation.
>
That's probably an implementation-defined issue, is it not?
>
I'm not sure whether it's implementation-defined or unspecified.
I don't see any mention of trap/non-value representations in Annex
J.
>
[...]
>
6.2.6.1 p 2;
>
So it's implementation-defined.  [...]
>
Quoting the standard so that everyone else doesn't have to go look
it up (and guess which edition you're referring to).  You might
consider doing that yourself.

I choose the contents of my comments to be what I think is
appropropriate under each individual set of circumstances.
Please keep your patronizing preaching to yourself.

Date Sujet#  Auteur
7 Aug 24 * how cast works?122Thiago Adams
7 Aug 24 +* Re: how cast works?7Thiago Adams
7 Aug 24 i+- Re: how cast works?1Keith Thompson
12 Aug 24 i`* Re: how cast works?5Tim Rentsch
12 Aug 24 i `* Re: how cast works?4Vir Campestris
12 Aug 24 i  `* Challenge/exercise problem - signum() function3Tim Rentsch
12 Aug 24 i   `* Re: Challenge/exercise problem - signum() function2Lew Pitcher
12 Aug 24 i    `- Re: Challenge/exercise problem - signum() function1Tim Rentsch
7 Aug 24 +* Re: how cast works?107Dan Purgert
7 Aug 24 i+- Re: how cast works?1Keith Thompson
8 Aug 24 i+- Re: how cast works?1Lawrence D'Oliveiro
8 Aug 24 i+* Re: how cast works?101Thiago Adams
8 Aug 24 ii+* Re: how cast works?25Bart
8 Aug 24 iii`* Re: how cast works?24Michael S
8 Aug 24 iii +- Re: how cast works?1Thiago Adams
8 Aug 24 iii `* Re: how cast works?22Bart
8 Aug 24 iii  +* Re: how cast works?5Thiago Adams
8 Aug 24 iii  i+- Re: how cast works?1Thiago Adams
8 Aug 24 iii  i+* Re: how cast works?2Bart
8 Aug 24 iii  ii`- Re: how cast works?1Thiago Adams
8 Aug 24 iii  i`- Re: how cast works?1Keith Thompson
8 Aug 24 iii  `* Re: how cast works?16David Brown
8 Aug 24 iii   `* Re: how cast works?15Bart
9 Aug 24 iii    +* Re: how cast works?13David Brown
9 Aug 24 iii    i+* Re: how cast works?9Keith Thompson
9 Aug 24 iii    ii+* Re: how cast works?3Lawrence D'Oliveiro
9 Aug 24 iii    iii+- Re: how cast works?1Keith Thompson
9 Aug 24 iii    iii`- Re: how cast works?1James Kuyper
9 Aug 24 iii    ii`* Re: how cast works?5David Brown
9 Aug 24 iii    ii `* Re: how cast works?4Keith Thompson
12 Aug 24 iii    ii  `* Re: how cast works?3Tim Rentsch
12 Aug 24 iii    ii   `* Re: how cast works?2Keith Thompson
3 Sep 24 iii    ii    `- Re: how cast works?1Tim Rentsch
9 Aug 24 iii    i`* Re: how cast works?3Bart
9 Aug 24 iii    i `* Re: how cast works?2David Brown
10 Aug 24 iii    i  `- Re: how cast works?1Bart
9 Aug 24 iii    `- Re: how cast works?1Lawrence D'Oliveiro
8 Aug 24 ii`* Re: how cast works?75Keith Thompson
8 Aug 24 ii `* Re: how cast works?74Thiago Adams
8 Aug 24 ii  +* Re: how cast works?72Bart
9 Aug 24 ii  i+* Re: how cast works?47Keith Thompson
9 Aug 24 ii  ii+* Re: how cast works?38Bart
9 Aug 24 ii  iii+* Re: how cast works?2David Brown
12 Aug 24 ii  iiii`- Re: how cast works?1Bart
9 Aug 24 ii  iii+* Re: how cast works?29James Kuyper
9 Aug 24 ii  iiii+* Re: how cast works?14Bart
9 Aug 24 ii  iiiii+* Re: how cast works?3Keith Thompson
10 Aug 24 ii  iiiiii`* Re: how cast works?2Bart
10 Aug 24 ii  iiiiii `- Re: how cast works?1Keith Thompson
10 Aug 24 ii  iiiii`* Re: how cast works?10James Kuyper
13 Aug 24 ii  iiiii +- Re: how cast works?1David Brown
13 Aug 24 ii  iiiii +- Re: how cast works?1Bart
13 Aug 24 ii  iiiii `* Re: how cast works?7James Kuyper
13 Aug 24 ii  iiiii  `* Re: how cast works?6Bart
13 Aug 24 ii  iiiii   `* Re: how cast works?5Keith Thompson
13 Aug 24 ii  iiiii    `* Re: how cast works?4Bart
14 Aug 24 ii  iiiii     `* Re: how cast works?3Tim Rentsch
14 Aug 24 ii  iiiii      `* Re: how cast works?2Bart
18 Aug 24 ii  iiiii       `- Re: how cast works?1Tim Rentsch
9 Aug 24 ii  iiii+* Re: how cast works?2Keith Thompson
10 Aug 24 ii  iiiii`- Re: how cast works?1James Kuyper
9 Aug 24 ii  iiii`* Re: how cast works?12Kaz Kylheku
9 Aug 24 ii  iiii +* Re: how cast works?9Keith Thompson
10 Aug 24 ii  iiii i`* Re: how cast works?8Kaz Kylheku
10 Aug 24 ii  iiii i +* Re: how cast works?6Keith Thompson
10 Aug 24 ii  iiii i i+* Re: how cast works?3Kaz Kylheku
10 Aug 24 ii  iiii i ii+- Re: how cast works?1Keith Thompson
10 Aug 24 ii  iiii i ii`- Re: how cast works?1James Kuyper
10 Aug 24 ii  iiii i i`* Re: how cast works?2Bart
13 Aug 24 ii  iiii i i `- Re: how cast works?1David Brown
12 Aug 24 ii  iiii i `- Re: how cast works?1Tim Rentsch
10 Aug 24 ii  iiii +- Re: how cast works?1James Kuyper
12 Aug 24 ii  iiii `- Re: how cast works?1Tim Rentsch
9 Aug 24 ii  iii+* Re: how cast works?4Keith Thompson
9 Aug 24 ii  iiii`* Re: how cast works?3Bart
9 Aug 24 ii  iiii `* Re: how cast works?2Keith Thompson
9 Aug 24 ii  iiii  `- Re: how cast works?1Bart
12 Aug 24 ii  iii`* Re: how cast works?2Tim Rentsch
12 Aug 24 ii  iii `- Re: how cast works?1Bart
12 Aug 24 ii  ii`* Re: how cast works?8Tim Rentsch
12 Aug 24 ii  ii `* Re: how cast works?7Bart
12 Aug 24 ii  ii  +- Re: how cast works?1Keith Thompson
12 Aug 24 ii  ii  `* Re: how cast works?5Tim Rentsch
12 Aug 24 ii  ii   `* Re: how cast works?4Keith Thompson
12 Aug 24 ii  ii    `* Re: how cast works?3Ben Bacarisse
12 Aug 24 ii  ii     `* Re: how cast works?2Tim Rentsch
12 Aug 24 ii  ii      `- Re: how cast works?1Keith Thompson
9 Aug 24 ii  i`* Re: how cast works?24Thiago Adams
9 Aug 24 ii  i +* Re: how cast works?2Bart
9 Aug 24 ii  i i`- Re: how cast works?1Keith Thompson
9 Aug 24 ii  i +* Re: how cast works?19David Brown
9 Aug 24 ii  i i`* Re: how cast works?18Thiago Adams
9 Aug 24 ii  i i +* Re: how cast works?3Thiago Adams
9 Aug 24 ii  i i i+- Re: how cast works?1David Brown
9 Aug 24 ii  i i i`- Re: how cast works?1Keith Thompson
9 Aug 24 ii  i i +* Re: how cast works?11David Brown
10 Aug 24 ii  i i i`* Re: how cast works?10Bart
10 Aug 24 ii  i i i `* Re: how cast works?9Thiago Adams
10 Aug 24 ii  i i i  `* Re: how cast works?8Bart
11 Aug 24 ii  i i i   `* Re: how cast works?7Thiago Adams
11 Aug 24 ii  i i i    `* Re: how cast works?6Keith Thompson
9 Aug 24 ii  i i `* Re: how cast works?3Keith Thompson
9 Aug 24 ii  i `* Re: how cast works?2Keith Thompson
9 Aug 24 ii  `- Re: how cast works?1David Brown
8 Aug 24 i`* Re: how cast works?3Stefan Ram
7 Aug 24 +* Re: how cast works?6Keith Thompson
8 Aug 24 `- Re: how cast works?1Lawrence D'Oliveiro

Haut de la page

Les messages affichés proviennent d'usenet.

NewsPortal