Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C Programming > Re: Pointer Arithmetic & UB

Reply
Thread Tools

Re: Pointer Arithmetic & UB

 
 
Ken Brody
Guest
Posts: n/a
 
      12-12-2012
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.

 
Reply With Quote
 
 
 
 
Ken Brody
Guest
Posts: n/a
 
      12-12-2012
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


 
Reply With Quote
 
 
 
 
glen herrmannsfeldt
Guest
Posts: n/a
 
      12-12-2012
Ken Brody <(E-Mail Removed)> 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
 
Reply With Quote
 
glen herrmannsfeldt
Guest
Posts: n/a
 
      12-13-2012
Robert Wessel <(E-Mail Removed)> 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
 
Reply With Quote
 
Malcolm McLean
Guest
Posts: n/a
 
      12-17-2012
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.

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Pointer to pointer or reference to pointer A C++ 7 07-05-2011 07:49 PM
Pointer to pointer Vs References to Pointer bansalvikrant@gmail.com C++ 4 07-02-2009 10:20 AM
passing the address of a pointer to a func that doesnt recieve a pointer-to-a-pointer jimjim C Programming 16 03-27-2006 11:03 PM
Usual Arithmetic Conversions-arithmetic expressions joshc C Programming 5 03-31-2005 02:23 AM
Pointer-to-pointer-to-pointer question masood.iqbal@lycos.com C Programming 10 02-04-2005 02:57 AM



Advertisments