[Gllug] My and my malloc() problems....

Nix nix at esperi.demon.co.uk
Sun Dec 30 17:32:12 UTC 2001


On Fri, 28 Dec 2001, Daniel Clusells moaned:
> Hi All,
> 
> Although I'm a little bit out of practice I think of C as my first language.
> I think I can give you a hint about that problem.
> 
> You probably  need to use 'volatile' in some variable. For example:

This is likely only the case if longjmp() is being used, and that little
horror should be used as little as possible, IMHO.

> 1.- c=1;
> 2.- {code}
> 3.- c=2;
> 
> If you don't use directly the variable c in the block 2 the compiler

Depends what you mean by `directly'. If a pointer used in 2 may alias
`c' (the criteria for which are fearfully complex), then the store into
c cannot be optimized away.

> When you use -g to compile it doesn't optimize the code and for that reason
> it works.

Always wrong in GCC. -g never, *ever* changes generated code, and -g -O2
is permitted --- otherwise bugs that only showed under optimization
would be very hard to fix.

If you find a circumstance in which -g changes the contents of code
sections, it is a bug in GCC.

-- 
`Mmm... Maybe I just like strong women that can hurt me?'
     --- Vadik, on female throat-cutting doctors

-- 
Gllug mailing list  -  Gllug at linux.co.uk
http://list.ftech.net/mailman/listinfo/gllug




More information about the GLLUG mailing list