Re: const and static (was: C vs. assembly...)

cdg@nullstone.com (Christopher Glaeser)
2 Apr 1996 23:35:01 -0500

          From comp.compilers

Related articles
Re: C code .vs. Assembly code for Microcontrollers/DSPs ? sberg@camtronics.com (1996-03-14)
Re: C code .vs. Assembly code for Microcontrollers/DSPs ? cdg@nullstone.com (1996-03-16)
const and static (was: C vs. assembly...) mark@omnifest.uwm.edu (1996-03-25)
const and static (was: C vs. assembly...) fjh@cs.mu.OZ.AU (1996-03-27)
Re: const and static (was: C vs. assembly...) cdg@nullstone.com (1996-03-27)
Re: const and static (was: C vs. assembly...) mason@ease.com (1996-03-29)
Re: const and static (was: C vs. assembly...) cdg@nullstone.com (1996-04-02)
Re: const and static (was: C vs. assembly...) jmccarty@sun1307.spd.dsccc.com (1996-04-02)
Re: const and static (was: C vs. assembly...) KingD@rnd1.indy.tce.com (King Dale) (1996-04-11)
Re: const and static (was: C vs. assembly...) cdg@nullstone.com (1996-04-12)
Re: const and static (was: C vs. assembly...) cdg@nullstone.com (1996-04-12)
Re: const and static (was: C vs. assembly...) sharris@fox.nstn.ca (1996-04-13)
Re: const and static (was: C vs. assembly...) mfinney@inmind.com (1996-04-16)
[1 later articles]
| List of all articles for this month |
From: cdg@nullstone.com (Christopher Glaeser)
Newsgroups: comp.compilers
Date: 2 Apr 1996 23:35:01 -0500
Organization: Compilers Central
References: 96-03-106 96-03-091 96-03-181 96-03-215
Keywords: C, optimize, parallel

Mark Mason <mason@ease.com> writes:
> Although the above code is a bad example for the point I want to make,
> the above statement is not entirely correct.
> It is possible with a little work to write an (obviously contrived)
> example which uses a static local variable to communicate between two
> tasks. Having the compiler change the variable from static to auto
> would definitely change the behavior of this program.


Yes, it is possible to write non-conforming programs with undefined
behavior, such that an optimization will change the behavior of the
program. However, programs with undefined behavior should not be used
to prove that an optimzation is "not entirely correct".


A more compelling argument starts with a program that conforms to the
standard, and then shows why a particular optimization changes the
behavior, and is therefore not correct. Of course, if such a
conforming program does not exit, the proof becomes a bit tedious.


If we are allowed to use programs with undefined behavior to discredit
an optimization, then all optimizations can be shown to be "not
entirely correct".


Regards,
Christopher Glaeser cdg@nullstone.com
Nullstone Corporation http://www.nullstone.com
--


Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.