Re: unused for all platforms



On Mon, 18 Feb 2002, Miroslaw Dobrzanski-Neumann wrote:

> On Mon, Feb 18, 2002 at 03:10:14PM +0100, Daniel Egger wrote:
> > Am Mon, 2002-02-18 um 09.49 schrieb Miroslaw Dobrzanski-Neumann:
> > 
> > > As I know there is no compiler that generates code for statements like
> > > "p = *&p"
> > 
> > Actually that would have to be "p = p" which is valid C and means
> > what it reads (i.e. Initialise p with the value it had before, whatever
> > that was; probably random).There was some hefty discussion on the gcc
> > mailinglist whether that really is the proper fix to prevent the
> > "variable blah might be used uninitialised" warnings and the only
> > conclusion they have reached was that it's totally valid C but should
> > be discouraged.
> why?
> p = *&p guarantees that p does not go into cpu register (its address is
> taken).

No, it only gurantees that its not a "pure" register only variable. p=*&p
also probably refreshes the state of the in-register copy of the variable
from thew in-memory copy (in case someone went and overwrote it behind
everybodies back).

What kind of optimisations it inhibits (after all, compilers with good
optimisations do a bit more flow analysis and don't make far
reaching assumptions just because an address of a variable was taken
somewhere) to make a compiler look at the computer as having m2m
operations is compiler (version) dependant.

> We use this construct as DO_NOT_CLOBBER(p) when using DCE exceptions.
> 
> > Better would be to use the special attributes of gcc or pragmas of
> > other compilers to hint the compiler into the right direction. Of course
> > avoiding unused parameters would be the best idea after all.
> which ends in many #ifdef/#pragma parts which not necessary improve the
> readability of code.
> 
> BTW.
> What about implementing exception handling in terms of setjmp/longjmp like DCE
> does?
> -- 
> Miroslaw Dobrzanski-Neumann
> 
> MOSAIC SOFTWARE AG
> Base Development and Research
> Tel +49-2225-882-291
> Fax +49-2225-882-201
> E-mail: mne mosaic-ag com
> 

	Sander

	I see a dark sail on the horizon
	Set under a dark cloud that hides the sun
	Bring me my Broadsword and clear understanding




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]