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


Groups > comp.lang.c > #29128 > unrolled thread

Pointer Arithmetic & UB

Started byEdward Rutherford <edward.p.rutherford79@REMOVETHIS.gmail.com>
First post2012-12-10 17:14 +0000
Last post2012-12-10 20:20 -0500
Articles 19 on this page of 99 — 21 participants

Back to article view | Back to comp.lang.c


Contents

  Pointer Arithmetic & UB Edward Rutherford <edward.p.rutherford79@REMOVETHIS.gmail.com> - 2012-12-10 17:14 +0000
    Re: Pointer Arithmetic & UB "christian.bau" <christian.bau@cbau.wanadoo.co.uk> - 2012-12-10 09:35 -0800
    Re: Pointer Arithmetic & UB James Kuyper <jameskuyper@verizon.net> - 2012-12-10 12:55 -0500
      Re: Pointer Arithmetic & UB Eric Sosman <esosman@comcast-dot-net.invalid> - 2012-12-10 13:25 -0500
        Re: Pointer Arithmetic & UB falk@rahul.net (Edward A. Falk) - 2012-12-11 00:46 +0000
          Re: Pointer Arithmetic & UB James Kuyper <jameskuyper@verizon.net> - 2012-12-10 21:28 -0500
            Re: Pointer Arithmetic & UB Ken Brody <kenbrody@spamcop.net> - 2012-12-12 14:36 -0500
              Re: Pointer Arithmetic & UB glen herrmannsfeldt <gah@ugcs.caltech.edu> - 2012-12-12 20:35 +0000
              Re: Pointer Arithmetic & UB James Kuyper <jameskuyper@verizon.net> - 2012-12-12 15:57 -0500
              Re: Pointer Arithmetic & UB Eric Sosman <esosman@comcast-dot-net.invalid> - 2012-12-12 16:02 -0500
                Re: Pointer Arithmetic & UB James Kuyper <jameskuyper@verizon.net> - 2012-12-12 16:13 -0500
                  Re: Pointer Arithmetic & UB Eric Sosman <esosman@comcast-dot-net.invalid> - 2012-12-12 21:18 -0500
                    Re: Pointer Arithmetic & UB James Kuyper <jameskuyper@verizon.net> - 2012-12-12 22:42 -0500
                    Re: Pointer Arithmetic & UB Phil Carmody <thefatphil_demunged@yahoo.co.uk> - 2012-12-17 12:04 +0200
                      Re: Pointer Arithmetic & UB Eric Sosman <esosman@comcast-dot-net.invalid> - 2012-12-17 08:47 -0500
                        Re: Pointer Arithmetic & UB Ben Bacarisse <ben.usenet@bsb.me.uk> - 2012-12-17 14:58 +0000
                          Re: Pointer Arithmetic & UB Eric Sosman <esosman@comcast-dot-net.invalid> - 2012-12-17 10:59 -0500
                            Re: Pointer Arithmetic & UB Ben Bacarisse <ben.usenet@bsb.me.uk> - 2012-12-17 17:26 +0000
                              Re: Pointer Arithmetic & UB Shao Miller <sha0.miller@gmail.com> - 2012-12-17 19:33 -0500
                                Re: Pointer Arithmetic & UB Ken Brody <kenbrody@spamcop.net> - 2012-12-20 11:00 -0500
                                  Re: Pointer Arithmetic & UB Tim Rentsch <txr@alumni.caltech.edu> - 2012-12-20 10:03 -0800
                                    Re: Pointer Arithmetic & UB Ben Bacarisse <ben.usenet@bsb.me.uk> - 2012-12-20 22:02 +0000
                                      Re: Pointer Arithmetic & UB Tim Rentsch <txr@alumni.caltech.edu> - 2012-12-21 13:09 -0800
                                        Re: Pointer Arithmetic & UB glen herrmannsfeldt <gah@ugcs.caltech.edu> - 2012-12-21 22:40 +0000
                                          Re: Pointer Arithmetic & UB Ken Brody <kenbrody@spamcop.net> - 2012-12-21 23:39 -0500
                                            Re: Pointer Arithmetic & UB glen herrmannsfeldt <gah@ugcs.caltech.edu> - 2012-12-22 06:50 +0000
                                          Re: Pointer Arithmetic & UB Tim Rentsch <txr@alumni.caltech.edu> - 2012-12-22 00:15 -0800
                                            Re: Pointer Arithmetic & UB glen herrmannsfeldt <gah@ugcs.caltech.edu> - 2012-12-22 10:34 +0000
                                              Re: Pointer Arithmetic & UB Tim Rentsch <txr@alumni.caltech.edu> - 2012-12-22 09:32 -0800
                                                Re: Pointer Arithmetic & UB glen herrmannsfeldt <gah@ugcs.caltech.edu> - 2012-12-23 09:38 +0000
                                                  Re: Pointer Arithmetic & UB Tim Rentsch <txr@alumni.caltech.edu> - 2012-12-23 09:55 -0800
                                                Re: Pointer Arithmetic & UB Ken Brody <kenbrody@spamcop.net> - 2012-12-26 13:35 -0500
                                                  Re: Pointer Arithmetic & UB Tim Rentsch <txr@alumni.caltech.edu> - 2012-12-27 09:03 -0800
                                                    Re: Pointer Arithmetic & UB Ken Brody <kenbrody@spamcop.net> - 2012-12-27 21:31 -0500
                                                      Re: Pointer Arithmetic & UB Philip Lantz <prl@canterey.us> - 2012-12-28 01:55 -0800
                                                      Re: Pointer Arithmetic & UB Tim Rentsch <txr@alumni.caltech.edu> - 2012-12-29 13:43 -0800
                                                    Re: Pointer Arithmetic & UB Philip Lantz <prl@canterey.us> - 2012-12-28 01:39 -0800
                                                      Re: Pointer Arithmetic & UB glen herrmannsfeldt <gah@ugcs.caltech.edu> - 2012-12-28 11:31 +0000
                                                        Re: Pointer Arithmetic & UB Keith Thompson <kst-u@mib.org> - 2012-12-28 08:47 -0800
                                                      Re: Pointer Arithmetic & UB Tim Rentsch <txr@alumni.caltech.edu> - 2012-12-29 17:45 -0800
                                                        Re: Pointer Arithmetic & UB glen herrmannsfeldt <gah@ugcs.caltech.edu> - 2012-12-30 04:06 +0000
                                                          Re: Pointer Arithmetic & UB Tim Rentsch <txr@alumni.caltech.edu> - 2013-01-02 10:08 -0800
                                            Re: Pointer Arithmetic & UB Ken Brody <kenbrody@spamcop.net> - 2012-12-26 13:29 -0500
                                              Re: Pointer Arithmetic & UB Tim Rentsch <txr@alumni.caltech.edu> - 2012-12-27 07:55 -0800
                                              Re: Pointer Arithmetic & UB Tim Rentsch <txr@alumni.caltech.edu> - 2012-12-27 08:01 -0800
                                                Re: Pointer Arithmetic & UB Ken Brody <kenbrody@spamcop.net> - 2012-12-27 21:10 -0500
                                                  Re: Pointer Arithmetic & UB Tim Rentsch <txr@alumni.caltech.edu> - 2012-12-29 18:03 -0800
                                        Re: Pointer Arithmetic & UB Ben Bacarisse <ben.usenet@bsb.me.uk> - 2012-12-23 03:48 +0000
                                          Re: Pointer Arithmetic & UB Tim Rentsch <txr@alumni.caltech.edu> - 2012-12-23 10:22 -0800
                                            Re: Pointer Arithmetic & UB Ben Bacarisse <ben.usenet@bsb.me.uk> - 2012-12-27 10:34 +0000
                                              Re: Pointer Arithmetic & UB Tim Rentsch <txr@alumni.caltech.edu> - 2012-12-27 10:16 -0800
                                                Re: Pointer Arithmetic & UB Ben Bacarisse <ben.usenet@bsb.me.uk> - 2013-01-10 17:26 +0000
                                  Re: Pointer Arithmetic & UB Robert Wessel <robertwessel2@yahoo.com> - 2012-12-20 12:21 -0600
                                    Re: Pointer Arithmetic & UB James Kuyper <jameskuyper@verizon.net> - 2012-12-20 13:40 -0500
                                      Re: Pointer Arithmetic & UB Robert Wessel <robertwessel2@yahoo.com> - 2012-12-20 13:32 -0600
                                        Re: Pointer Arithmetic & UB James Kuyper <jameskuyper@verizon.net> - 2012-12-20 14:58 -0500
                                        Re: Pointer Arithmetic & UB glen herrmannsfeldt <gah@ugcs.caltech.edu> - 2012-12-20 21:54 +0000
                                    Re: Pointer Arithmetic & UB Lanarcam <lanarcam1@yahoo.fr> - 2012-12-20 19:49 +0100
                                      Re: Pointer Arithmetic & UB Phil Carmody <thefatphil_demunged@yahoo.co.uk> - 2012-12-21 02:38 +0200
                                    Re: Pointer Arithmetic & UB Ken Brody <kenbrody@spamcop.net> - 2012-12-21 14:33 -0500
                                  Re: Pointer Arithmetic & UB Shao Miller <sha0.miller@gmail.com> - 2012-12-21 03:18 -0500
                                    Re: Pointer Arithmetic & UB Tim Rentsch <txr@alumni.caltech.edu> - 2012-12-21 13:16 -0800
                                      Re: Pointer Arithmetic & UB Shao Miller <sha0.miller@gmail.com> - 2012-12-21 17:57 -0500
                                        Re: Pointer Arithmetic & UB glen herrmannsfeldt <gah@ugcs.caltech.edu> - 2012-12-21 23:52 +0000
                                          Re: Pointer Arithmetic & UB Shao Miller <sha0.miller@gmail.com> - 2012-12-21 19:47 -0500
                                        Re: Pointer Arithmetic & UB Tim Rentsch <txr@alumni.caltech.edu> - 2012-12-21 22:54 -0800
                                          Re: Pointer Arithmetic & UB Shao Miller <sha0.miller@gmail.com> - 2012-12-22 03:31 -0500
                                            Re: Pointer Arithmetic & UB Tim Rentsch <txr@alumni.caltech.edu> - 2012-12-22 09:16 -0800
                                              Re: Pointer Arithmetic & UB Shao Miller <sha0.miller@gmail.com> - 2012-12-24 04:23 -0500
                                                Re: Pointer Arithmetic & UB Tim Rentsch <txr@alumni.caltech.edu> - 2012-12-27 11:07 -0800
                    Re: Pointer Arithmetic & UB Tim Rentsch <txr@alumni.caltech.edu> - 2012-12-17 02:33 -0800
                  Re: Pointer Arithmetic & UB Tim Rentsch <txr@alumni.caltech.edu> - 2012-12-17 02:18 -0800
          Re: Pointer Arithmetic & UB Noob <root@127.0.0.1> - 2012-12-11 11:36 +0100
            Re: Pointer Arithmetic & UB "christian.bau" <christian.bau@cbau.wanadoo.co.uk> - 2012-12-11 10:00 -0800
              Re: Pointer Arithmetic & UB Phil Carmody <thefatphil_demunged@yahoo.co.uk> - 2012-12-17 12:11 +0200
          Re: Pointer Arithmetic & UB Eric Sosman <esosman@comcast-dot-net.invalid> - 2012-12-11 15:27 -0500
            Re: Pointer Arithmetic & UB glen herrmannsfeldt <gah@ugcs.caltech.edu> - 2012-12-11 21:09 +0000
          Re: Pointer Arithmetic & UB Ken Brody <kenbrody@spamcop.net> - 2012-12-12 14:30 -0500
            Re: Pointer Arithmetic & UB Keith Thompson <kst-u@mib.org> - 2012-12-12 11:42 -0800
            Re: Pointer Arithmetic & UB Ken Brody <kenbrody@spamcop.net> - 2012-12-12 17:12 -0500
            Re: Pointer Arithmetic & UB Phil Carmody <thefatphil_demunged@yahoo.co.uk> - 2012-12-17 12:16 +0200
    Re: Pointer Arithmetic & UB Prathamesh Kulkarni <bilbotheelffriend@gmail.com> - 2012-12-10 12:04 -0800
      Re: Pointer Arithmetic & UB James Kuyper <jameskuyper@verizon.net> - 2012-12-10 15:29 -0500
        Re: Pointer Arithmetic & UB Prathamesh Kulkarni <bilbotheelffriend@gmail.com> - 2012-12-10 12:44 -0800
          Re: Pointer Arithmetic & UB Prathamesh Kulkarni <bilbotheelffriend@gmail.com> - 2012-12-10 12:47 -0800
            Re: Pointer Arithmetic & UB James Kuyper <jameskuyper@verizon.net> - 2012-12-10 16:02 -0500
              Re: Pointer Arithmetic & UB Prathamesh Kulkarni <bilbotheelffriend@gmail.com> - 2012-12-10 13:08 -0800
                Re: Pointer Arithmetic & UB Ken Brody <kenbrody@spamcop.net> - 2012-12-12 14:26 -0500
              Re: Pointer Arithmetic & UB Greg Martin <greg@softsprocket.com> - 2012-12-10 14:55 -0800
          Re: Pointer Arithmetic & UB Sjouke Burry <s@b> - 2012-12-10 21:18 +0000
          Re: Pointer Arithmetic & UB falk@rahul.net (Edward A. Falk) - 2012-12-11 00:48 +0000
        Re: Pointer Arithmetic & UB glen herrmannsfeldt <gah@ugcs.caltech.edu> - 2012-12-10 21:01 +0000
        Re: Pointer Arithmetic & UB Ken Brody <kenbrody@spamcop.net> - 2012-12-12 14:24 -0500
          Re: Pointer Arithmetic & UB Robert Wessel <robertwessel2@yahoo.com> - 2012-12-12 14:34 -0600
          Re: Pointer Arithmetic & UB glen herrmannsfeldt <gah@ugcs.caltech.edu> - 2012-12-12 20:45 +0000
            Re: Pointer Arithmetic & UB Robert Wessel <robertwessel2@yahoo.com> - 2012-12-12 15:29 -0600
              Re: Pointer Arithmetic & UB glen herrmannsfeldt <gah@ugcs.caltech.edu> - 2012-12-13 02:02 +0000
          Re: Pointer Arithmetic & UB Malcolm McLean <malcolm.mclean5@btinternet.com> - 2012-12-17 05:57 -0800
      Re: Pointer Arithmetic & UB pete <pfiland@mindspring.com> - 2012-12-10 20:20 -0500

Page 5 of 5 — ← Prev page 1 2 3 4 [5]


#29375

FromPhil Carmody <thefatphil_demunged@yahoo.co.uk>
Date2012-12-17 12:16 +0200
Message-ID<87txrlj85n.fsf@bazspaz.fatphil.org>
In reply to#29175
Ken Brody <kenbrody@spamcop.net> writes:
> On 12/10/2012 7:46 PM, Edward A. Falk wrote:
> > In article <ka59e6$mq7$1@dont-email.me>,
> > Eric Sosman  <esosman@comcast-dot-net.invalid> wrote:
> >>
> >>      A colleague who did some work on IBM's AS/400 (they've
> >> changed the name; I forget the new one) told me that simply
> >> trying to calculate an out-of-range pointer yielded a null
> >> pointer as a result.
> >
> > Heh; learn something new every day.  I never would have guessed
> > that there was an actual architecture that would blow up with
> > this construct.
> >
> > I assume that *(a+(i-j)) would be ok?
> 
> No.  There is no requirement that the value of "i-j" be calculated
> prior to adding it to "a".  (Check the numerous threads here involving
> using parentheses to "fix" UB in things involving such constructs as
> "i + (i++)".) Operator precedence only guarantees how the expression
> is to be interpreted, not the actual order of evaluation.

The "*(a+(i-j))" expression has *nothing* in common with the part of the 
"i+(i++)" that pertains to UB. That brackets fail to do something in an
unrelated situation is basically irrelevant.

Phil
-- 
I'm not saying that google groups censors my posts, but there's a strong link
between me saying "google groups sucks" in articles, and them disappearing.

Oh - I guess I might be saying that google groups censors my posts.

[toc] | [prev] | [next] | [standalone]


#29134

FromPrathamesh Kulkarni <bilbotheelffriend@gmail.com>
Date2012-12-10 12:04 -0800
Message-ID<e4659f49-c39e-4367-bbad-c2724a3ebd13@googlegroups.com>
In reply to#29128
Instead, of i and j
would *(a + 20 - 15) still have
undefined behaviour ? Probably any C compiler
will evaluate 20 - 15 during translation, but
does the standard require constant expression
to be evaluated during translation
even if it is a sub-expression
as in the above case ?

Thanks ;)

[toc] | [prev] | [next] | [standalone]


#29136

FromJames Kuyper <jameskuyper@verizon.net>
Date2012-12-10 15:29 -0500
Message-ID<50C6461E.40208@verizon.net>
In reply to#29134
On 12/10/2012 03:04 PM, Prathamesh Kulkarni wrote:
> Instead, of i and j
> would *(a + 20 - 15) still have
> undefined behaviour ? Probably any C compiler
> will evaluate 20 - 15 during translation, but
> does the standard require constant expression
> to be evaluated during translation
> even if it is a sub-expression
> as in the above case ?

No, it does not. It would be an unusual compiler that failed to do so,
but it is not required.

[toc] | [prev] | [next] | [standalone]


#29137

FromPrathamesh Kulkarni <bilbotheelffriend@gmail.com>
Date2012-12-10 12:44 -0800
Message-ID<232fe1b0-d8fa-42e2-85d8-12bcba97a4a1@googlegroups.com>
In reply to#29136
On Monday, 10 December 2012 15:29:18 UTC-5, James Kuyper  wrote:
> On 12/10/2012 03:04 PM, Prathamesh Kulkarni wrote:
> 
> > Instead, of i and j
> 
> > would *(a + 20 - 15) still have
> 
> > undefined behaviour ? Probably any C compiler
> 
> > will evaluate 20 - 15 during translation, but
> 
> > does the standard require constant expression
> 
> > to be evaluated during translation
> 
> > even if it is a sub-expression
> 
> > as in the above case ?
> 
> 
> 
> No, it does not. It would be an unusual compiler that failed to do so,
> 
> but it is not required.

Yes, I got that, that's why I deleted my post immediately
after posting. How were you able to see it ?
How 

[toc] | [prev] | [next] | [standalone]


#29138

FromPrathamesh Kulkarni <bilbotheelffriend@gmail.com>
Date2012-12-10 12:47 -0800
Message-ID<f954578b-8c15-44ee-9f34-0fb2bf90af61@googlegroups.com>
In reply to#29137
On Monday, 10 December 2012 15:44:37 UTC-5, Prathamesh Kulkarni  wrote:
> On Monday, 10 December 2012 15:29:18 UTC-5, James Kuyper  wrote:
> 
> > On 12/10/2012 03:04 PM, Prathamesh Kulkarni wrote:
> 
> > 
> 
> > > Instead, of i and j
> 
> > 
> 
> > > would *(a + 20 - 15) still have
> 
> > 
> 
> > > undefined behaviour ? Probably any C compiler
> 
> > 
> 
> > > will evaluate 20 - 15 during translation, but
> 
> > 
> 
> > > does the standard require constant expression
> 
> > 
> 
> > > to be evaluated during translation
> 
> > 
> 
> > > even if it is a sub-expression
> 
> > 
> 
> > > as in the above case ?
> 
> > 
> 
> > 
> 
> > 
> 
> > No, it does not. It would be an unusual compiler that failed to do so,
> 
> > 
> 
> > but it is not required.
> 
> 
> 
> Yes, I got that, that's why I deleted my post immediately
> 
> after posting. How were you able to see it ?
> 
> How

It repeated the word "How" ;)
Is there some problem with the google interface ?

[toc] | [prev] | [next] | [standalone]


#29140

FromJames Kuyper <jameskuyper@verizon.net>
Date2012-12-10 16:02 -0500
Message-ID<50C64DEF.2050506@verizon.net>
In reply to#29138
On 12/10/2012 03:47 PM, Prathamesh Kulkarni wrote:
...
>> Yes, I got that, that's why I deleted my post immediately

Forged cancellation notices used to be common; as a result, most news
servers now ignore cancellation requests that come from other news
servers. Your request presumably deleted the message from Google's
archive, which is one of the largest and most widely used on the planet
- but it probably didn't delete many of the thousands of other copies
stored stored in various places around the world.

>> after posting. How were you able to see it ?
>>
>> How
> 
> It repeated the word "How" ;)
> Is there some problem with the google interface ?

That's sort of like asking if the sea is wet. I recommend getting better
news server (I can strongly recommend eternalseptember.org, which is
free) and a monitoring it using decent newsreader (my favorite is
Mozilla thunderbird, but many people prefer other news readers).

[toc] | [prev] | [next] | [standalone]


#29141

FromPrathamesh Kulkarni <bilbotheelffriend@gmail.com>
Date2012-12-10 13:08 -0800
Message-ID<2a27f6cf-5f1f-45f8-8925-d27b56b06b7a@googlegroups.com>
In reply to#29140
On Monday, 10 December 2012 16:02:39 UTC-5, James Kuyper  wrote:
> On 12/10/2012 03:47 PM, Prathamesh Kulkarni wrote:
> 
> ...
> 
> >> Yes, I got that, that's why I deleted my post immediately
> 
> 
> 
> Forged cancellation notices used to be common; as a result, most news
> 
> servers now ignore cancellation requests that come from other news
> 
> servers. Your request presumably deleted the message from Google's
> 
> archive, which is one of the largest and most widely used on the planet
> 
> - but it probably didn't delete many of the thousands of other copies
> 
> stored stored in various places around the world.
> 
> 
> 
> >> after posting. How were you able to see it ?
> 
> >>
> 
> >> How
> 
> > 
> 
> > It repeated the word "How" ;)
> 
> > Is there some problem with the google interface ?
> 
> 
> 
> That's sort of like asking if the sea is wet. I recommend getting better
> 
> news server (I can strongly recommend eternalseptember.org, which is
> 
> free) and a monitoring it using decent newsreader (my favorite is
> 
> Mozilla thunderbird, but many people prefer other news readers).

Thanks, I will give a try to eternalseptember.org,

[toc] | [prev] | [next] | [standalone]


#29174

FromKen Brody <kenbrody@spamcop.net>
Date2012-12-12 14:26 -0500
Message-ID<kaalpm$3uf$2@dont-email.me>
In reply to#29141
On 12/10/2012 4:08 PM, Prathamesh Kulkarni wrote:
> On Monday, 10 December 2012 16:02:39 UTC-5, James Kuyper  wrote:
>> On 12/10/2012 03:47 PM, Prathamesh Kulkarni wrote:
[...]
>>> Is there some problem with the google interface ?
>>
>>
>>
>> That's sort of like asking if the sea is wet. I recommend getting better
>> news server (I can strongly recommend eternalseptember.org, which is
>> free) and a monitoring it using decent newsreader (my favorite is
>> Mozilla thunderbird, but many people prefer other news readers).
>
> Thanks, I will give a try to eternalseptember.org,

There's a hyphen there:

     eternal-september.org

[toc] | [prev] | [next] | [standalone]


#29143

FromGreg Martin <greg@softsprocket.com>
Date2012-12-10 14:55 -0800
Message-ID<vLtxs.10170$eK6.8648@newsfe31.iad>
In reply to#29140
On 12-12-10 01:02 PM, James Kuyper wrote:
> On 12/10/2012 03:47 PM, Prathamesh Kulkarni wrote:
> ...
>>> Yes, I got that, that's why I deleted my post immediately
>
> Forged cancellation notices used to be common; as a result, most news
> servers now ignore cancellation requests that come from other news
> servers. Your request presumably deleted the message from Google's
> archive, which is one of the largest and most widely used on the planet
> - but it probably didn't delete many of the thousands of other copies
> stored stored in various places around the world.
>
>>> after posting. How were you able to see it ?
>>>
>>> How
>>
>> It repeated the word "How" ;)
>> Is there some problem with the google interface ?
>
> That's sort of like asking if the sea is wet. I recommend getting better
> news server (I can strongly recommend eternalseptember.org, which is
> free) and a monitoring it using decent newsreader (my favorite is
> Mozilla thunderbird, but many people prefer other news readers).
>

I think that should be eternal-september.org.

[toc] | [prev] | [next] | [standalone]


#29142

FromSjouke Burry <s@b>
Date2012-12-10 21:18 +0000
Message-ID<XnsA125DE858696Bsjoukeburrysoesterbe@213.75.12.10>
In reply to#29137
Prathamesh Kulkarni <bilbotheelffriend@gmail.com> wrote in news:232fe1b0-
d8fa-42e2-85d8-12bcba97a4a1@googlegroups.com:

> On Monday, 10 December 2012 15:29:18 UTC-5, James Kuyper  wrote:
>> On 12/10/2012 03:04 PM, Prathamesh Kulkarni wrote:
>> 
>> > Instead, of i and j
>> 
>> > would *(a + 20 - 15) still have
>> 
>> > undefined behaviour ? Probably any C compiler
>> 
>> > will evaluate 20 - 15 during translation, but
>> 
>> > does the standard require constant expression
>> 
>> > to be evaluated during translation
>> 
>> > even if it is a sub-expression
>> 
>> > as in the above case ?
>> 
>> 
>> 
>> No, it does not. It would be an unusual compiler that failed to do so,
>> 
>> but it is not required.
> 
> Yes, I got that, that's why I deleted my post immediately
> after posting. How were you able to see it ?
> How 
> 

By looking carefully.....

[toc] | [prev] | [next] | [standalone]


#29145

Fromfalk@rahul.net (Edward A. Falk)
Date2012-12-11 00:48 +0000
Message-ID<ka5vt2$lq6$2@blue-new.rahul.net>
In reply to#29137
In article <232fe1b0-d8fa-42e2-85d8-12bcba97a4a1@googlegroups.com>,
Prathamesh Kulkarni  <bilbotheelffriend@gmail.com> wrote:
>
>Yes, I got that, that's why I deleted my post immediately
>after posting. How were you able to see it ?
>How 

News servers are not required to honor cancels, and many do
not.  Also, cancels can take time to propagate through the
network, so previous poster could have seen your article and
responded to it before it was deleted.

-- 
	-Ed Falk, falk@despams.r.us.com
	http://thespamdiaries.blogspot.com/

[toc] | [prev] | [next] | [standalone]


#29139

Fromglen herrmannsfeldt <gah@ugcs.caltech.edu>
Date2012-12-10 21:01 +0000
Message-ID<ka5ik6$o40$1@speranza.aioe.org>
In reply to#29136
James Kuyper <jameskuyper@verizon.net> wrote:
> On 12/10/2012 03:04 PM, Prathamesh Kulkarni wrote:
>> Instead, of i and j
>> would *(a + 20 - 15) still have
>> undefined behaviour ? Probably any C compiler
>> will evaluate 20 - 15 during translation, but
>> does the standard require constant expression
>> to be evaluated during translation
>> even if it is a sub-expression
>> as in the above case ?
 
> No, it does not. It would be an unusual compiler that 
> failed to do so, but it is not required.

Well, constant expressions in context where constants
are needed are required to be evaluated at compile time,
but this (whole) expression isn't constant.

In Fortran 66 and 77 you couldn't

      DIMENSION X(10+10)

but in C you always could. (Not counting VLAs)

It used to be suggested that one write Fortran constants with
the appropriate type, such as 0.0 instead of 0, to avoid
run-time conversion. One hoped that compilers would figure it
out, but you were never quite sure enough.

-- glen
> 

[toc] | [prev] | [next] | [standalone]


#29173

FromKen Brody <kenbrody@spamcop.net>
Date2012-12-12 14:24 -0500
Message-ID<kaalki$3uf$1@dont-email.me>
In reply to#29136
On 12/10/2012 3:29 PM, James Kuyper wrote:
> On 12/10/2012 03:04 PM, Prathamesh Kulkarni wrote:
>> Instead, of i and j
>> would *(a + 20 - 15) still have
>> undefined behaviour ? Probably any C compiler
>> will evaluate 20 - 15 during translation, but
>> does the standard require constant expression
>> to be evaluated during translation
>> even if it is a sub-expression
>> as in the above case ?
>
> No, it does not. It would be an unusual compiler that failed to do so,
> but it is not required.

When I went to college, there was a FORTRAN compiler aimed specifically at 
teaching FORTRAN programming.  Since it was expected that there would be 
more time spent compiling (and recompiling, after fixing errors) the program 
than in running it (the resulting program would in all likelihood be run 
only once), there was zero optimization done on the resulting code.  This 
made the compiler itself "lean and mean", allowing it to finish compiling 
(or getting to the errors) faster.  It didn't make sense to spend X amount 
of time optimizing a program, only to save less than X time once the program 
actually ran the one time it would be run.

I could see such an implementation of C being developed.

[toc] | [prev] | [next] | [standalone]


#29178

FromRobert Wessel <robertwessel2@yahoo.com>
Date2012-12-12 14:34 -0600
Message-ID<24qhc89qrvbhj8q2fngc65ee29cj9i1u49@4ax.com>
In reply to#29173
On Wed, 12 Dec 2012 14:24:05 -0500, Ken Brody <kenbrody@spamcop.net>
wrote:

>On 12/10/2012 3:29 PM, James Kuyper wrote:
>> On 12/10/2012 03:04 PM, Prathamesh Kulkarni wrote:
>>> Instead, of i and j
>>> would *(a + 20 - 15) still have
>>> undefined behaviour ? Probably any C compiler
>>> will evaluate 20 - 15 during translation, but
>>> does the standard require constant expression
>>> to be evaluated during translation
>>> even if it is a sub-expression
>>> as in the above case ?
>>
>> No, it does not. It would be an unusual compiler that failed to do so,
>> but it is not required.
>
>When I went to college, there was a FORTRAN compiler aimed specifically at 
>teaching FORTRAN programming.  Since it was expected that there would be 
>more time spent compiling (and recompiling, after fixing errors) the program 
>than in running it (the resulting program would in all likelihood be run 
>only once), there was zero optimization done on the resulting code.  This 
>made the compiler itself "lean and mean", allowing it to finish compiling 
>(or getting to the errors) faster.  It didn't make sense to spend X amount 
>of time optimizing a program, only to save less than X time once the program 
>actually ran the one time it would be run.


Good old Watfor and Watfiv...  In addition to doing no optimization
(although the IBM compiler did little or none in basic mode), it
allowed you to skip the heavyweight link step.  I remember on a
370/138 (maybe it was a 4341 by that point, memories fade), typical
student jobs (~100 cards in first semester Fortran), taking a couple
of seconds of CPU time, whereas the IBM compiler took half a minute.
Better diagnostics too.


>I could see such an implementation of C being developed.

But on what current platform would student size jobs take too long to
compile, with or without optimization turned on?

[toc] | [prev] | [next] | [standalone]


#29180

Fromglen herrmannsfeldt <gah@ugcs.caltech.edu>
Date2012-12-12 20:45 +0000
Message-ID<kaaqcg$gko$1@speranza.aioe.org>
In reply to#29173
Ken Brody <kenbrody@spamcop.net> wrote:

(snip on expression evaluation order)

> When I went to college, there was a FORTRAN compiler aimed specifically at 
> teaching FORTRAN programming.  Since it was expected that there would be 
> more time spent compiling (and recompiling, after fixing errors) the program 
> than in running it (the resulting program would in all likelihood be run 
> only once), there was zero optimization done on the resulting code.  This 
> made the compiler itself "lean and mean", allowing it to finish compiling 
> (or getting to the errors) faster.  It didn't make sense to spend X amount 
> of time optimizing a program, only to save less than X time once the program 
> actually ran the one time it would be run.

Maybe about that time, there was a story about benchmarks for Fortran
compilers. There was one that evaluated many complicated expressions,
mostly using statement functions. 

This benchmark was then given to the OS/360 Fortran H compiler with 
optimization level of 2, where it compiled very slowly and ran in 
pretty much no time at all. 

It turns out that the compiler expands statement functions inline
(seems to have been rare at the time), and then evaluates constant
expressions. The compiler did the whole calculation down to one
number to print out!
 
> I could see such an implementation of C being developed.

The favorite Fortran compilers I knew of for student programs were
WATFOR and WATFIV. Both are in-core compilers. They don't write out
an object program, but instead generate instructions in memory, ready
to run. 

I believe that there is a WAT-C, but don't know anything about it.

The WATCOM compilers don't seem to be in-core compilers.

I do remember MS had a Quick-C which might have been (and still be)
an in-core compiler.

-- glen

[toc] | [prev] | [next] | [standalone]


#29186

FromRobert Wessel <robertwessel2@yahoo.com>
Date2012-12-12 15:29 -0600
Message-ID<vithc8t9dfnam01bngfoaa6i9u2imu6sig@4ax.com>
In reply to#29180
On Wed, 12 Dec 2012 20:45:04 +0000 (UTC), glen herrmannsfeldt
<gah@ugcs.caltech.edu> wrote:

>Ken Brody <kenbrody@spamcop.net> wrote:
>
>(snip on expression evaluation order)
>
>> When I went to college, there was a FORTRAN compiler aimed specifically at 
>> teaching FORTRAN programming.  Since it was expected that there would be 
>> more time spent compiling (and recompiling, after fixing errors) the program 
>> than in running it (the resulting program would in all likelihood be run 
>> only once), there was zero optimization done on the resulting code.  This 
>> made the compiler itself "lean and mean", allowing it to finish compiling 
>> (or getting to the errors) faster.  It didn't make sense to spend X amount 
>> of time optimizing a program, only to save less than X time once the program 
>> actually ran the one time it would be run.
>
>Maybe about that time, there was a story about benchmarks for Fortran
>compilers. There was one that evaluated many complicated expressions,
>mostly using statement functions. 
>
>This benchmark was then given to the OS/360 Fortran H compiler with 
>optimization level of 2, where it compiled very slowly and ran in 
>pretty much no time at all. 
>
>It turns out that the compiler expands statement functions inline
>(seems to have been rare at the time), and then evaluates constant
>expressions. The compiler did the whole calculation down to one
>number to print out!
> 
>> I could see such an implementation of C being developed.
>
>The favorite Fortran compilers I knew of for student programs were
>WATFOR and WATFIV. Both are in-core compilers. They don't write out
>an object program, but instead generate instructions in memory, ready
>to run. 
>
>I believe that there is a WAT-C, but don't know anything about it.
>
>The WATCOM compilers don't seem to be in-core compilers.
>
>I do remember MS had a Quick-C which might have been (and still be)
>an in-core compiler.


QuickC was MS's IDE, a precursor to Visual C++ and Visual Studio.
Under the hood it used the contemporary MSC compilers.

[toc] | [prev] | [next] | [standalone]


#29191

Fromglen herrmannsfeldt <gah@ugcs.caltech.edu>
Date2012-12-13 02:02 +0000
Message-ID<kabcuu$t5a$1@speranza.aioe.org>
In reply to#29186
Robert Wessel <robertwessel2@yahoo.com> wrote:

(snip, I wrote)

>>I do remember MS had a Quick-C which might have been (and still be)
>>an in-core compiler.
 
> QuickC was MS's IDE, a precursor to Visual C++ and Visual Studio.
> Under the hood it used the contemporary MSC compilers.

I had one, as it came with the MSC compiler, but don't think I
ever used it.

Still, I always thought it had a different compiler inside.
Maybe not a lot different.

-- glen

[toc] | [prev] | [next] | [standalone]


#29401

FromMalcolm McLean <malcolm.mclean5@btinternet.com>
Date2012-12-17 05:57 -0800
Message-ID<fd284b6d-c843-4024-a4ed-a3d52c470ca2@googlegroups.com>
In reply to#29173
On Wednesday, December 12, 2012 7:24:05 PM UTC, Ken Brody wrote:
> On 12/10/2012 3:29 PM, James Kuyper wrote:
> 

> When I went to college, there was a FORTRAN compiler aimed specifically at 
> teaching FORTRAN programming.  Since it was expected that there would be 
> more time spent compiling (and recompiling, after fixing errors) the program 
> than in running it (the resulting program would in all likelihood be run 
> only once), there was zero optimization done on the resulting code.  This 
> made the compiler itself "lean and mean", allowing it to finish compiling 
> (or getting to the errors) faster.  It didn't make sense to spend X amount 
> of time optimizing a program, only to save less than X time once the program 
> actually ran the one time it would be run.
> 
Sometimes when you're developing code, you need to know that it's correct.
Other times you need to know that it's correct and fast enough.

For instance if you are developing a video game, then typically you'll 
write a bit of code, then run the game to see what effect your changes have
on the player's experience. So normally the program will have to run at the
same speed the end-user will be receiving. 

[toc] | [prev] | [next] | [standalone]


#29146

Frompete <pfiland@mindspring.com>
Date2012-12-10 20:20 -0500
Message-ID<50C68A6C.50DE@mindspring.com>
In reply to#29134
Prathamesh Kulkarni wrote:
> 
> Instead, of i and j
> would *(a + 20 - 15) still have
> undefined behaviour ? Probably any C compiler
> will evaluate 20 - 15 during translation, but
> does the standard require constant expression
> to be evaluated during translation
> even if it is a sub-expression
> as in the above case ?

(20 - 15) isn't a subexpression in the above case.

(a + 20 - 15) means (a + 20) - 15

-- 
pete

[toc] | [prev] | [standalone]


Page 5 of 5 — ← Prev page 1 2 3 4 [5]

Back to top | Article view | comp.lang.c


csiph-web