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


Groups > comp.lang.c > #104655

Re: lvalues from the ternary op

From Keith Thompson <kst-u@mib.org>
Newsgroups comp.lang.c
Subject Re: lvalues from the ternary op
Date 2017-02-24 14:56 -0800
Organization None to speak of
Message-ID <ln37f3i4ee.fsf@kst-u.example.com> (permalink)
References (15 earlier) <7cf3d284-16e8-4f6a-8f3a-b62b8fbcd9c5@googlegroups.com> <kfnlgsvtwax.fsf@x-alumni2.alumni.caltech.edu> <d74fd7b1-1dea-443d-8617-2be77c9b51ba@googlegroups.com> <lnfuj3ian8.fsf@kst-u.example.com> <6c8379ea-4a8a-4d88-9c3c-0c9e6d5aff04@googlegroups.com>

Show all headers | View raw


supercat@casperkitty.com writes:
> On Friday, February 24, 2017 at 2:42:07 PM UTC-6, Keith Thompson wrote:
>> supercat writes:
>> > True or false: the Standard specifies as a runtime constraint that stored
>> > value of an object of type "float" may not be accessed with an lvalue of
>> > type "unsigned".  Because this is a runtime constraint, the Standard
>> > allow implementations to do anything whatsoever if code violates it.  Such
>> > permission overrides anything else in the Standard that would otherwise
>> > define the behavior of the code.
>> 
>> False.  The term "runtime-constraint", introduced in C11, applies only
>> to calls to library functions specified in the optional Annex K.
>
> I believe that if the structure of a program violates a "shall" clause in
> the Standard in such a way as to require a diagnostic, such violation is
> referred to as a constraint violation.

Yes.  More precisely, a "shall" clause in a paragraph that's explicitly
labeled as a "constraint" is a constraint, and violating it requires a
diagnostic.

Do you think that your rephrasing of concepts already defined by the
standard is helpful?  I don't.

>                                         That would suggest that at least
> as far as ordinary English construction is concerned, a "shall" clause
> which is only applicable to run-time behavior would be a run-time
> constraint, though I see that a similar phrase with different hyphenation
> has been given another meaning.

I see, so "runtime constraint" is a phrase of your own invention.  (I'm
guessing you weren't familar with Annex K?)

It doesn't suggest that to me.  The word "constraint" has a very
specific meaning in the C standard, and that meaning does not apply to
run-time behavior (other than runtime-constraints, but that phrase
should be thought of as a single term; a runtime-constraint is not a
constraint).

> Since the phrase "a 'shall' or 'shall not' requirement that appears outside
> of a constraint or runtime-constraint" is a bit unwieldy, perhaps you can
> suggest something more to your liking?

What's wrong with calling it "undefined behavior", a term that almost
everyone here already understands perfectly well?  "Undefined behavior"
also covers things other than violations of "shall" clauses.

4p2:
    If a "shall" or "shall not" requirement that appears outside
    of a constraint or runtimeconstraint is violated, the behavior
    is undefined. Undefined behavior is otherwise indicated in this
    International Standard by the words "undefined behavior" or by
    the omission of any explicit definition of behavior. There is
    no difference in emphasis among these three; they all describe
    "behavior that is undefined".

[...]

> Most forms of Undefined Behavior are undefined by omission.

I'm skeptical of that claim, but I don't think it matters whether it's
valid or not.

>                                                              By contrast,
> code which violates "a 'shall' or 'shall not' requirement that appears
> outside of a constraint or runtime-constraint" invokes UB even if behavior
> would be defined in the absence of that requirement.

I suppose so.

[...]

>> > True or false: the Standard allows an implementation to process the
>> > statement "uf.u = 4;" in a way that writes to the stored value of the float
>> > value stored within "uf".
>> 
>> I suggest wording this more clearly.  One can write to an object, not to
>> a value; writing to an object updates the value that's stored in that
>> object.
>
> The Standard uses the phrase "have its stored value accessed" in 6.5p7;
> but I don't see any definition for "stored value".  An action that modifies
> something, however, would appear to be a write and consequently an "access".

The definition of "access" is "<execution-time action> to read or modify
the value of an object".  An object can be accessed; a value cannot.

[...]

>> It's quite possible that the standard's wording on union members is
>> internally inconsistent (that "quite possible" is mostly reflective of
>> my current state of ignorance on the matter).  One particular question
>> I'm curious about is whether the footnote in 6.5.2.3:
>> 
>>     If the member used to read the contents of a union object is
>>     not the same as the member last used to store a value in the
>>     object, the appropriate part of the object representation of
>>     the value is reinterpreted as an object representation in the
>>     new type as described in 6.2.6 (a process sometimes called
>>     "type punning). This might be a trap representation.
>> 
>> can be inferred from the normative wording of the standard.
>> (It clearly represents the intent of the committee.  The question
>> is whether that intent is sufficiently clearly stated in normative
>> text.)
>
> If code violates a "shall" requirement that is only applicable at runtime,
> it invokes UB regardless of whether behavior would be defined in the absence
> of that requirement.  If one part of the Standard would appear to define the
> behavior of certain actions, but most such actions would violate a "shall"
> requirement given in another part, the Standard's rules of construction
> would imply that the former is only applicable to those actions that comply
> with the latter requirement.

I'm unwilling to wade through all the stuff you've written here to
extract its meaning.  If you'd like to start again, using
standard-defined terminology where appropriate and citing the standard
itself to support your points, I'll take a look.

-- 
Keith Thompson (The_Other_Keith) kst-u@mib.org  <http://www.ghoti.net/~kst>
Working, but not speaking, for JetHead Development, Inc.
"We must do something.  This is something.  Therefore, we must do this."
    -- Antony Jay and Jonathan Lynn, "Yes Minister"

Back to comp.lang.c | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Re: lvalues from the ternary op Manfred <noname@invalid.add> - 2017-01-04 19:46 +0100
  Re: lvalues from the ternary op supercat@casperkitty.com - 2017-01-04 11:08 -0800
  Re: lvalues from the ternary op Ben Bacarisse <ben.usenet@bsb.me.uk> - 2017-01-04 21:10 +0000
    Re: lvalues from the ternary op Keith Thompson <kst-u@mib.org> - 2017-01-04 13:48 -0800
      Re: lvalues from the ternary op Ian Collins <ian-news@hotmail.com> - 2017-01-05 11:07 +1300
        Re: lvalues from the ternary op Keith Thompson <kst-u@mib.org> - 2017-01-04 14:20 -0800
      Re: lvalues from the ternary op supercat@casperkitty.com - 2017-01-04 14:41 -0800
        Re: lvalues from the ternary op Keith Thompson <kst-u@mib.org> - 2017-01-04 15:21 -0800
          Re: lvalues from the ternary op supercat@casperkitty.com - 2017-01-04 15:52 -0800
            Re: lvalues from the ternary op Keith Thompson <kst-u@mib.org> - 2017-01-04 16:37 -0800
            Re: lvalues from the ternary op Keith Thompson <kst-u@mib.org> - 2017-01-04 18:31 -0800
              Re: lvalues from the ternary op Tim Rentsch <txr@alumni.caltech.edu> - 2017-01-13 17:26 -0800
                Re: lvalues from the ternary op Keith Thompson <kst-u@mib.org> - 2017-01-13 17:49 -0800
                Re: lvalues from the ternary op Tim Rentsch <txr@alumni.caltech.edu> - 2017-01-15 22:53 -0800
    Re: lvalues from the ternary op Tim Rentsch <txr@alumni.caltech.edu> - 2017-01-13 17:08 -0800
      Re: lvalues from the ternary op Ben Bacarisse <ben.usenet@bsb.me.uk> - 2017-01-14 02:15 +0000
        Re: lvalues from the ternary op Tim Rentsch <txr@alumni.caltech.edu> - 2017-01-15 22:51 -0800
      Re: lvalues from the ternary op luser droog <luser.droog@gmail.com> - 2017-01-16 23:09 -0800
        Re: lvalues from the ternary op Manfred <noname@invalid.add> - 2017-01-18 14:51 +0100
          Re: lvalues from the ternary op Keith Thompson <kst-u@mib.org> - 2017-01-18 09:59 -0800
            Re: lvalues from the ternary op Lew Pitcher <lew.pitcher@digitalfreehold.ca> - 2017-01-18 13:12 -0500
            Re: lvalues from the ternary op supercat@casperkitty.com - 2017-01-18 12:11 -0800
              Re: lvalues from the ternary op Keith Thompson <kst-u@mib.org> - 2017-01-18 12:45 -0800
                Re: lvalues from the ternary op supercat@casperkitty.com - 2017-01-18 14:07 -0800
                Re: lvalues from the ternary op Keith Thompson <kst-u@mib.org> - 2017-01-18 14:40 -0800
                Re: lvalues from the ternary op supercat@casperkitty.com - 2017-01-18 16:10 -0800
                Re: lvalues from the ternary op Keith Thompson <kst-u@mib.org> - 2017-01-18 18:08 -0800
                Re: lvalues from the ternary op supercat@casperkitty.com - 2017-01-19 06:44 -0800
                Re: lvalues from the ternary op Keith Thompson <kst-u@mib.org> - 2017-01-19 08:40 -0800
                Re: lvalues from the ternary op supercat@casperkitty.com - 2017-01-19 12:32 -0800
                Re: lvalues from the ternary op supercat@casperkitty.com - 2017-01-20 06:01 -0800
                Re: lvalues from the ternary op Keith Thompson <kst-u@mib.org> - 2017-01-20 08:15 -0800
                Re: lvalues from the ternary op supercat@casperkitty.com - 2017-01-20 10:51 -0800
                Re: lvalues from the ternary op Keith Thompson <kst-u@mib.org> - 2017-01-20 11:32 -0800
                Re: lvalues from the ternary op supercat@casperkitty.com - 2017-01-20 13:41 -0800
                Re: lvalues from the ternary op supercat@casperkitty.com - 2017-01-23 07:04 -0800
                Re: lvalues from the ternary op Ike Naar <ike@iceland.freeshell.org> - 2017-01-23 17:59 +0000
                Re: lvalues from the ternary op supercat@casperkitty.com - 2017-01-23 10:57 -0800
                Re: lvalues from the ternary op Tim Rentsch <txr@alumni.caltech.edu> - 2017-01-31 08:45 -0800
                Re: lvalues from the ternary op Keith Thompson <kst-u@mib.org> - 2017-01-31 09:13 -0800
                Re: lvalues from the ternary op supercat@casperkitty.com - 2017-01-31 10:17 -0800
                Re: lvalues from the ternary op Ben Bacarisse <ben.usenet@bsb.me.uk> - 2017-02-01 01:51 +0000
                Re: lvalues from the ternary op supercat@casperkitty.com - 2017-02-01 14:24 -0800
                Re: lvalues from the ternary op Ben Bacarisse <ben.usenet@bsb.me.uk> - 2017-02-02 03:07 +0000
                Re: lvalues from the ternary op Tim Rentsch <txr@alumni.caltech.edu> - 2017-02-04 04:43 -0800
                Re: lvalues from the ternary op supercat@casperkitty.com - 2017-02-04 08:01 -0800
                Re: lvalues from the ternary op Tim Rentsch <txr@alumni.caltech.edu> - 2017-02-09 09:06 -0800
                Re: lvalues from the ternary op supercat@casperkitty.com - 2017-02-09 11:56 -0800
                Re: lvalues from the ternary op Tim Rentsch <txr@alumni.caltech.edu> - 2017-02-12 10:29 -0800
                Re: lvalues from the ternary op supercat@casperkitty.com - 2017-02-12 13:43 -0800
                Re: lvalues from the ternary op Tim Rentsch <txr@alumni.caltech.edu> - 2017-02-19 21:44 -0800
                Re: lvalues from the ternary op supercat@casperkitty.com - 2017-02-20 08:15 -0800
                Re: lvalues from the ternary op Tim Rentsch <txr@alumni.caltech.edu> - 2017-02-24 07:58 -0800
                Re: lvalues from the ternary op supercat@casperkitty.com - 2017-02-24 10:00 -0800
                Re: lvalues from the ternary op scott@slp53.sl.home (Scott Lurndal) - 2017-02-24 18:58 +0000
                Re: lvalues from the ternary op supercat@casperkitty.com - 2017-02-24 13:03 -0800
                Re: lvalues from the ternary op Keith Thompson <kst-u@mib.org> - 2017-02-24 14:11 -0800
                Re: lvalues from the ternary op Keith Thompson <kst-u@mib.org> - 2017-02-24 12:42 -0800
                Re: lvalues from the ternary op Keith Thompson <kst-u@mib.org> - 2017-02-24 13:49 -0800
                Re: lvalues from the ternary op supercat@casperkitty.com - 2017-02-24 13:58 -0800
                Re: lvalues from the ternary op Keith Thompson <kst-u@mib.org> - 2017-02-24 14:56 -0800
                Re: lvalues from the ternary op supercat <flatfinger@casperkitty.com> - 2017-02-25 14:00 -0800
                Re: lvalues from the ternary op Tim Rentsch <txr@alumni.caltech.edu> - 2017-02-25 09:23 -0800
                Re: lvalues from the ternary op Tim Rentsch <txr@alumni.caltech.edu> - 2017-02-25 09:43 -0800
                Re: lvalues from the ternary op Kelsey Bjarnason <kbjarnason@gmail.com> - 2017-02-01 22:47 -0800
                Re: lvalues from the ternary op supercat@casperkitty.com - 2017-02-02 10:12 -0800
                Re: lvalues from the ternary op Tim Rentsch <txr@alumni.caltech.edu> - 2017-02-04 07:51 -0800
                Re: lvalues from the ternary op supercat@casperkitty.com - 2017-02-04 08:18 -0800
                Re: lvalues from the ternary op Tim Rentsch <txr@alumni.caltech.edu> - 2017-02-09 08:58 -0800
                Re: lvalues from the ternary op Tim Rentsch <txr@alumni.caltech.edu> - 2017-02-04 04:00 -0800
                Re: lvalues from the ternary op Kelsey Bjarnason <kbjarnason@gmail.com> - 2017-02-04 09:35 -0800
                Re: lvalues from the ternary op Tim Rentsch <txr@alumni.caltech.edu> - 2017-02-04 09:35 -0800
                Re: lvalues from the ternary op Robert Wessel <robertwessel2@yahoo.com> - 2017-01-31 13:36 -0600
                Re: lvalues from the ternary op supercat@casperkitty.com - 2017-01-31 12:23 -0800
                Re: lvalues from the ternary op Tim Rentsch <txr@alumni.caltech.edu> - 2017-02-01 13:48 -0800
                Re: lvalues from the ternary op Tim Rentsch <txr@alumni.caltech.edu> - 2017-01-31 08:53 -0800
            Re: lvalues from the ternary op Manfred <noname@invalid.add> - 2017-01-19 14:10 +0100
        Re: lvalues from the ternary op Tim Rentsch <txr@alumni.caltech.edu> - 2017-01-30 12:05 -0800

csiph-web