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


Groups > comp.lang.c > #163798

Re: Does this program have the specified behavior?

From Keith Thompson <Keith.S.Thompson+u@gmail.com>
Newsgroups comp.lang.c
Subject Re: Does this program have the specified behavior?
Date 2021-12-11 16:45 -0800
Organization None to speak of
Message-ID <87fsqyabxn.fsf@nosuchdomain.example.com> (permalink)
References (2 earlier) <L6KdnUDjcci1FAn8nZ2dnUU7-V_NnZ2d@giganews.com> <sn230n$q4t$1@dont-email.me> <3e59b2b4-88f9-4bd1-8cf7-eb7baee8c214n@googlegroups.com> <86y24s7q7i.fsf@linuxsc.com> <sp2uoe$q7f$1@z-news.wcss.wroc.pl>

Show all headers | View raw


antispam@math.uni.wroc.pl writes:
[...]
> AFAICS currently there is accepted view among theorists that
> changing non-terminating behavior into terminating behaviour
> is valid program transformation.  Concerning C standard
> relevant part in N1570 seem to be 5.1.2.3 point 6.  IIUC
> if program does not terminate on abstract machine clause
> about files at program termination is empty: it places no
> obligation on implementation.  It seems that also clause
> about interactive streams places no obligation on
> implementation when program performs no I/O.  So it seems
> that according to N1570 changing non-terminating program
> into terminating one is allowed.
>
> At practical level gcc seem to keep infinite loop with empty
> body.  I can imagine why gcc is doing that...

N1570 6.8.5p6 is relevant:

    An iteration statement whose controlling expression is not a
    constant expression, that performs no input/output operations, does
    not access volatile objects, and performs no synchronization or
    atomic operations in its body, controlling expression, or (in the
    case of a for statement) its expression-3, may be assumed by the
    implementation to terminate.

with a footnote:

    This is intended to allow compiler transformations such as removal
    of empty loops even when termination cannot be proven.

This was added in C11.

Personally, I dislike it, partly because it's written in terms of what
the implementation may assume rather than the behavior of a program.

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

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


Thread

Do this program have the specified behavior? olcott <NoOne@NoWhere.com> - 2021-11-16 21:33 -0600
  Does this program have the specified behavior? olcott <NoOne@NoWhere.com> - 2021-11-16 22:46 -0600
    Re: Does this program have the specified behavior? "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2021-11-16 21:12 -0800
      Re: Does this program have the specified behavior? Mark Bluemel <mark.bluemel@gmail.com> - 2021-11-17 00:28 -0800
        Re: Does this program have the specified behavior? olcott <NoOne@NoWhere.com> - 2021-11-17 08:33 -0600
        Re: Does this program have the specified behavior? Tim Rentsch <tr.17687@z991.linuxsc.com> - 2021-12-10 01:40 -0800
          Re: Does this program have the specified behavior? Richard Damon <Richard@Damon-Family.org> - 2021-12-10 07:56 -0500
            Re: Does this program have the specified behavior? Tim Rentsch <tr.17687@z991.linuxsc.com> - 2021-12-11 09:40 -0800
              Re: Does this program have the specified behavior? Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2021-12-11 16:37 -0800
                Re: Does this program have the specified behavior? Tim Rentsch <tr.17687@z991.linuxsc.com> - 2021-12-12 09:29 -0800
          Re: Does this program have the specified behavior? antispam@math.uni.wroc.pl - 2021-12-11 19:38 +0000
            Re: Does this program have the specified behavior? Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2021-12-11 16:45 -0800
            Re: Does this program have the specified behavior? Tim Rentsch <tr.17687@z991.linuxsc.com> - 2021-12-12 08:53 -0800
    Re: Does this program have the specified behavior? Richard Damon <Richard@Damon-Family.org> - 2021-11-17 06:53 -0500
      Re: Does this program have the specified behavior? olcott <NoOne@NoWhere.com> - 2021-11-17 08:49 -0600
        Re: Does this program have the specified behavior? Juha Nieminen <nospam@thanks.invalid> - 2021-11-18 06:32 +0000
          Re: Does this program have the specified behavior? Ben Bacarisse <ben.usenet@bsb.me.uk> - 2021-11-18 11:15 +0000
            Re: Does this program have the specified behavior? olcott <NoOne@NoWhere.com> - 2021-11-18 08:59 -0600
          Re: Does this program have the specified behavior? olcott <NoOne@NoWhere.com> - 2021-11-18 08:58 -0600
    Re: Does this program have the specified behavior? Anurag Ranjan <anuragranjan630@gmail.com> - 2021-11-17 22:00 +0000

csiph-web