Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.fortran > #40910

Re: Is goto Still Considered Harmful?

From "James Van Buskirk" <not_valid@comcast.net>
Newsgroups comp.lang.fortran, comp.lang.c
Subject Re: Is goto Still Considered Harmful?
Date 2014-03-14 10:36 -0600
Organization A noiseless patient Spider
Message-ID <lfvb69$vth$1@dont-email.me> (permalink)
References (4 earlier) <20140313153944.695@kylheku.com> <lfte37$p8k$1@dont-email.me> <20140313174032.771@kylheku.com> <lfttnk$kg8$1@dont-email.me> <lfu2h6$btd$1@dont-email.me>

Cross-posted to 2 groups.

Show all headers | View raw


"James Kuyper" <jameskuyper@verizon.net> wrote in message 
news:lfu2h6$btd$1@dont-email.me...

> On 03/13/2014 11:40 PM, James Van Buskirk wrote:

>> "Kaz Kylheku" <kaz@kylheku.com> wrote in message
>> news:20140313174032.771@kylheku.com...
>>> ["Followup-To:" header set to comp.lang.c.]

>> Posted to clf because the nature of the question is central to
>> an issue due to Fortran interoperability (_Bool <-> LOGICAL(C_BOOL)).

>>> On 2014-03-13, James Van Buskirk <not_valid@comcast.net> wrote:

>>>> At last!  A C programmer to inflict the Question on!  Now, what if
>>>> true is a const _Bool with internal representation B'00000010'
>>>> and var is also an _Bool.  Does the assert happen if NDEBUG is not
>>>> on?

>>> The code generated by the assert macro, when NDEBUG is not present, 
>>> should
>>> not
>>> treat this expression any differently than  something like

>>>   if (var = true) ...

>>> The assignment must happen if NDEBUG is absent, and its result tests as
>>> true.

>> Yes, this last line of code above is perhaps a better illustration
>> of the issue.  My impression was that assignment between variables
>> of the same integer type in C was to copy all the bits, ...

> Not quite - the value of the right operand of an assignment expression
> is determined (a process that may involve the usual arithmetic
> conversions), and is then converted to the destination type (if
> different).

Part of the premise of this subthread is that both left and right
operands have the same intrinsic type, _Bool.  See above.
In n1124.pdf, section 6.3 I read:

"Conversion of an operand value to a compatible type causes no
change to the value or the representation."

Doesn't that mean that the compiler is just supposed to copy
bits?

>             A representation of that value in the destination type is
> then placed in the destination object. For any type where there are two
> or more different ways to represent the same value, there's no guarantee
> as to which of those ways gets chosen; it needn't be the same as the
> representation used in the source object, even if they have exactly the
> same type. Even if the value and sign bits are the same, the values of
> the padding bits (if any) can be completely different.

As noted above, this is inconsistent with my understanding of
the passage quoted above.

>> ... and that
>> the result of the assignment was the value that the variable got
>> assigned.

>> But what is that value in this case?  If the low bit of an _Bool
>> is the only significant bit, then the value of B'00000010' is 0;
>> if at least the two low bits are significant, then the value is
>> 2, which, being nonzero, is true, and if any value but
>> B'00000000' and B'00000001' is a trap value, then the value is
>> undefined.   It seems to me that C99 allows the compiler to
>> choose any of these behaviors, or does it in fact require one
>> of them rather than the others?

> A _Bool is only required to be able to store two values: 0 and 1, a
> requirement that can be met by having 1 value bit and 7 padding bits.
> Whether _Bool can store larger values is unspecified. Larger values
> can't be assigned to a _Bool object, because conversion to _Bool is part
> of the assignment process.

But it seems to me that they can when assigning from _Bool to
_Bool.

>                            Such values, if they can be stored, could
> only be created by type punning.

Creating the first _Bool with a value outside the set {0,1}
in an assignment chain is, of course, another matter entirely,
but there are several ways it can happen.  Painfully, it can
happen in pre-MIL-STD 1753 Fortran code which can be broken
in a newfangled compiler that supports C_BOOL /= -1.

> The standard also doesn't specify that any particular bit must be the
> value bit - in principle, the single bit that is set in B'00000010'
> could be the only bit used by _Bool, though that seems unlikely.

-- 
write(*,*) transfer((/17.392111325966148d0,6.5794487871554595D-85, &
6.0134700243160014d-154/),(/'x'/)); end

Back to comp.lang.fortran | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Is goto Still Considered Harmful? Lynn McGuire <lmc@winsim.com> - 2014-03-12 11:02 -0500
  Re: Is goto Still Considered Harmful? James Kuyper <jameskuyper@verizon.net> - 2014-03-12 12:17 -0400
  Re: Is goto Still Considered Harmful? nospam@see.signature (Richard Maine) - 2014-03-12 09:20 -0700
    Re: Is goto Still Considered Harmful? Lynn McGuire <lmc@winsim.com> - 2014-03-18 16:30 -0500
      Re: Is goto Still Considered Harmful? glen herrmannsfeldt <gah@ugcs.caltech.edu> - 2014-03-18 21:48 +0000
        Re: Is goto Still Considered Harmful? Lynn McGuire <lmc@winsim.com> - 2014-03-18 19:10 -0500
          Re: Is goto Still Considered Harmful? "Terence" <tbwright@bigpond.net.au> - 2014-03-19 20:39 +1100
          Re: Is goto Still Considered Harmful? ftinetti@gmail.com - 2014-03-19 03:41 -0700
      Re: Is goto Still Considered Harmful? ftinetti@gmail.com - 2014-03-18 16:45 -0700
      Re: Is goto Still Considered Harmful? dpb <none@non.net> - 2014-03-18 19:14 -0500
      Re: Is goto Still Considered Harmful? Geoff <geoff@invalid.invalid> - 2014-03-18 17:36 -0700
        Re: Is goto Still Considered Harmful? James Kuyper <jameskuyper@verizon.net> - 2014-03-19 07:34 -0400
          Re: Is goto Still Considered Harmful? "BartC" <bc@freeuk.com> - 2014-03-19 12:08 +0000
            Re: Is goto Still Considered Harmful? James Kuyper <jameskuyper@verizon.net> - 2014-03-19 10:07 -0400
              Re: Is goto Still Considered Harmful? Richard <rgrdev_@gmail.com> - 2014-03-19 17:05 +0100
            Re: Is goto Still Considered Harmful? Lynn McGuire <lmc@winsim.com> - 2014-03-19 12:27 -0500
              Re: Is goto Still Considered Harmful? dpb <none@non.net> - 2014-03-19 13:04 -0500
                Re: Is goto Still Considered Harmful? dpb <none@non.net> - 2014-03-19 13:26 -0500
                Re: Is goto Still Considered Harmful? Lynn McGuire <lmc@winsim.com> - 2014-03-19 13:36 -0500
                Re: Is goto Still Considered Harmful? dpb <none@non.net> - 2014-03-19 14:02 -0500
                Re: Is goto Still Considered Harmful? Lynn McGuire <lmc@winsim.com> - 2014-03-19 13:36 -0500
              Re: Is goto Still Considered Harmful? Gordon Sande <Gordon.Sande@gmail.com> - 2014-03-19 16:48 -0300
      Re: Is goto Still Considered Harmful? "Terence" <tbwright@bigpond.net.au> - 2014-03-19 20:35 +1100
        Re: Is goto Still Considered Harmful? Lynn McGuire <lmc@winsim.com> - 2014-03-19 12:26 -0500
  Re: Is goto Still Considered Harmful? Gordon Sande <Gordon.Sande@gmail.com> - 2014-03-12 13:23 -0300
    Re: Is goto Still Considered Harmful? e p chandler <epc8@juno.com> - 2014-03-12 10:05 -0700
  Re: Is goto Still Considered Harmful? Kaz Kylheku <kaz@kylheku.com> - 2014-03-12 16:47 +0000
  Re: Is goto Still Considered Harmful? "BartC" <bc@freeuk.com> - 2014-03-12 18:50 +0000
    Re: Is goto Still Considered Harmful? Gordon Sande <Gordon.Sande@gmail.com> - 2014-03-12 16:16 -0300
    Re: Is goto Still Considered Harmful? <william@wilbur.25thandClement.com> - 2014-03-12 12:49 -0700
    Re: Is goto Still Considered Harmful? "Qolin" <noone@nowhere.com> - 2014-03-12 21:54 +0000
      Re: Is goto Still Considered Harmful? Lynn McGuire <lmc@winsim.com> - 2014-03-12 16:57 -0500
        Re: Is goto Still Considered Harmful? "Qolin" <noone@nowhere.com> - 2014-03-12 22:00 +0000
          Re: Is goto Still Considered Harmful? John Harper <john.harper@vuw.ac.nz> - 2014-03-13 11:23 +1300
      Re: Is goto Still Considered Harmful? Keith Thompson <kst-u@mib.org> - 2014-03-12 15:36 -0700
      Re: Is goto Still Considered Harmful? Robert Wessel <robertwessel2@yahoo.com> - 2014-03-12 23:40 -0500
        Re: Is goto Still Considered Harmful? David Brown <david.brown@hesbynett.no> - 2014-03-13 11:25 +0100
        Re: Is goto Still Considered Harmful? Thomas Jahns <jahns@idontlikespam.dkrz.de> - 2014-03-14 11:24 +0100
          Re: Is goto Still Considered Harmful? Robert Wessel <robertwessel2@yahoo.com> - 2014-03-14 23:32 -0500
          Re: Is goto Still Considered Harmful? Dr Nick <nospam-4@temporary-address.org.uk> - 2014-03-15 13:43 +0000
            Re: Is goto Still Considered Harmful? David Brown <david.brown@hesbynett.no> - 2014-03-15 16:28 +0100
              Re: Is goto Still Considered Harmful? Dr Nick <nospam-4@temporary-address.org.uk> - 2014-03-15 16:01 +0000
                Re: Is goto Still Considered Harmful? David Brown <david.brown@hesbynett.no> - 2014-03-17 08:51 +0100
    Re: Is goto Still Considered Harmful? David Brown <david.brown@hesbynett.no> - 2014-03-13 11:22 +0100
  Re: Is goto Still Considered Harmful? Jake <thatcadguy@gmail.com> - 2014-03-12 12:25 -0700
  Re: Is goto Still Considered Harmful? ralph <nt_consulting@yahoo.com> - 2014-03-12 15:34 -0500
  Re: Is goto Still Considered Harmful? jt@toerring.de (Jens Thoms Toerring) - 2014-03-13 01:06 +0000
    Re: Is goto Still Considered Harmful? fj <francois.jacq@irsn.fr> - 2014-03-12 18:31 -0700
      Re: Is goto Still Considered Harmful? wclodius@earthlink.net (William Clodius) - 2014-03-12 21:08 -0600
        Re: Is goto Still Considered Harmful? Dick Hendrickson <dick.hendrickson@att.net> - 2014-03-13 10:54 -0500
          Re: Is goto Still Considered Harmful? glen herrmannsfeldt <gah@ugcs.caltech.edu> - 2014-03-13 19:53 +0000
            Re: Is goto Still Considered Harmful? "Qolin" <noone@nowhere.com> - 2014-03-13 20:16 +0000
          Re: Is goto Still Considered Harmful? wclodius@earthlink.net (William Clodius) - 2014-03-13 21:57 -0600
    Re: Is goto Still Considered Harmful? wilson <winslole@udayton.edu> - 2014-03-13 03:59 -0400
      Re: Is goto Still Considered Harmful? wilson <winslole@udayton.edu> - 2014-03-13 05:02 -0400
    Re: Is goto Still Considered Harmful? Louis Krupp <lkrupp@nospam.pssw.com.invalid> - 2014-03-13 07:42 -0600
      Re: Is goto Still Considered Harmful? Richard <rgrdev_@gmail.com> - 2014-03-13 14:56 +0100
  Re: Is goto Still Considered Harmful? robin.vowels@gmail.com - 2014-03-13 00:59 -0700
  Re: Is goto Still Considered Harmful? Wolfgang Kilian <kilian@invalid.com> - 2014-03-13 09:10 +0100
  Re: Is goto Still Considered Harmful? Thomas Koenig <tkoenig@netcologne.de> - 2014-03-13 21:09 +0000
    Re: Is goto Still Considered Harmful? "Qolin" <noone@nowhere.com> - 2014-03-13 21:24 +0000
      Re: Is goto Still Considered Harmful? glen herrmannsfeldt <gah@ugcs.caltech.edu> - 2014-03-13 22:36 +0000
        Re: Is goto Still Considered Harmful? nospam@see.signature (Richard Maine) - 2014-03-13 17:54 -0700
          Re: Is goto Still Considered Harmful? robert.corbett@oracle.com - 2014-03-13 23:43 -0700
        Re: Is goto Still Considered Harmful? robin.vowels@gmail.com - 2014-03-13 18:07 -0700
        Re: Is goto Still Considered Harmful? Robert Wessel <robertwessel2@yahoo.com> - 2014-03-13 23:02 -0500
          Re: Is goto Still Considered Harmful? glen herrmannsfeldt <gah@ugcs.caltech.edu> - 2014-03-14 04:07 +0000
            Re: Is goto Still Considered Harmful? Robert Wessel <robertwessel2@yahoo.com> - 2014-03-13 23:56 -0500
          Re: Is goto Still Considered Harmful? helbig@astro.multiCLOTHESvax.de (Phillip Helbig---undress to reply) - 2014-03-14 09:17 +0000
        Re: Is goto Still Considered Harmful? Thomas Koenig <tkoenig@netcologne.de> - 2014-03-15 11:57 +0000
          Re: Is goto Still Considered Harmful? wclodius@earthlink.net (William Clodius) - 2014-03-15 16:38 -0600
            Re: Is goto Still Considered Harmful? Gary Scott <garylscott@sbcglobal.net> - 2014-03-15 18:09 -0500
              Re: Is goto Still Considered Harmful? wclodius@earthlink.net (William Clodius) - 2014-03-15 19:57 -0600
                Re: Is goto Still Considered Harmful? nospam@see.signature (Richard Maine) - 2014-03-15 19:41 -0700
    Re: Is goto Still Considered Harmful? Kaz Kylheku <kaz@kylheku.com> - 2014-03-13 22:42 +0000
      Re: Is goto Still Considered Harmful? "James Van Buskirk" <not_valid@comcast.net> - 2014-03-13 17:13 -0600
        Re: Is goto Still Considered Harmful? Keith Thompson <kst-u@mib.org> - 2014-03-13 16:46 -0700
          Re: Is goto Still Considered Harmful? glen herrmannsfeldt <gah@ugcs.caltech.edu> - 2014-03-14 01:17 +0000
            Re: Is goto Still Considered Harmful? Robert Wessel <robertwessel2@yahoo.com> - 2014-03-13 23:04 -0500
              Re: Is goto Still Considered Harmful? David Brown <david.brown@hesbynett.no> - 2014-03-14 10:41 +0100
                Re: Is goto Still Considered Harmful? Kaz Kylheku <kaz@kylheku.com> - 2014-03-14 09:55 +0000
                Re: Is goto Still Considered Harmful? David Brown <david.brown@hesbynett.no> - 2014-03-14 13:16 +0100
                Re: Is goto Still Considered Harmful? Seebs <usenet-nospam@seebs.net> - 2014-03-18 21:08 +0000
                Re: Is goto Still Considered Harmful? James Kuyper <jameskuyper@verizon.net> - 2014-03-18 17:41 -0400
            Re: Is goto Still Considered Harmful? robin.vowels@gmail.com - 2014-03-20 03:55 -0700
        Re: Is goto Still Considered Harmful? Kaz Kylheku <kaz@kylheku.com> - 2014-03-14 00:45 +0000
          Re: Is goto Still Considered Harmful? "James Van Buskirk" <not_valid@comcast.net> - 2014-03-13 21:40 -0600
            Re: Is goto Still Considered Harmful? James Kuyper <jameskuyper@verizon.net> - 2014-03-14 01:02 -0400
              Re: Is goto Still Considered Harmful? "James Van Buskirk" <not_valid@comcast.net> - 2014-03-14 10:36 -0600
                Re: Is goto Still Considered Harmful? Ben Bacarisse <ben.usenet@bsb.me.uk> - 2014-03-14 17:30 +0000
                Re: Is goto Still Considered Harmful? James Kuyper <jameskuyper@verizon.net> - 2014-03-14 13:51 -0400
                Re: Is goto Still Considered Harmful? Keith Thompson <kst-u@mib.org> - 2014-03-14 13:12 -0700
            Re: Is goto Still Considered Harmful? Kaz Kylheku <kaz@kylheku.com> - 2014-03-14 05:29 +0000
              Re: Is goto Still Considered Harmful? "James Van Buskirk" <not_valid@comcast.net> - 2014-03-14 10:47 -0600
                Re: Is goto Still Considered Harmful? Ben Bacarisse <ben.usenet@bsb.me.uk> - 2014-03-14 17:43 +0000
                Re: Is goto Still Considered Harmful? James Kuyper <jameskuyper@verizon.net> - 2014-03-14 13:52 -0400
            Re: Is goto Still Considered Harmful? Stephen Sprunk <stephen@sprunk.org> - 2014-03-16 17:15 -0500
              Re: Is goto Still Considered Harmful? Keith Thompson <kst-u@mib.org> - 2014-03-16 16:04 -0700
    Re: Is goto Still Considered Harmful? Kaz Kylheku <kaz@kylheku.com> - 2014-03-14 05:11 +0000
  Re: Is goto Still Considered Harmful? "Terence" <tbwright@bigpond.net.au> - 2014-03-14 08:32 +1100
    Re: Is goto Still Considered Harmful? Richard Damon <Richard@Damon-Family.org> - 2014-03-14 23:10 -0400

csiph-web