POV-Ray : Newsgroups : povray.general : pov source gcc3 problem : Re: pov source gcc3 problem Server Time
6 Aug 2024 02:22:18 EDT (-0400)
  Re: pov source gcc3 problem  
From: Pandora
Date: 7 Aug 2002 16:15:23
Message: <3d517fdb@news.povray.org>
"Warp" <war### [at] tagpovrayorg> wrote in message
news:3d508498@news.povray.org...
> Pandora <pan### [at] pandora-softwarecom> wrote:
> >     Which you can fix with brackets (which also fixes all other
problems,
>
>   Wrong. It doesn't fix the max(i++, j++) problem.
>

    Ah, yes, true. That slipped my mind, but can be solved in the same way
as the efficiency issue, see below :

> > the efficiency issue (which'll more often than not get handled by
> > an optimising compiler anyway)).
>
>   Wrong. For example if you call a function to get the value of the
> parameter, eg. max(function1(), function2()), the compiler can't optimize
> that double call away unless it can inline the function in question.

    Easily solved by doing :

a=function1();
b=function2();
c=max(a,b);

> (And if the function *does* return a different value when called again,
the
> whole max() macro will simply give the wrong result for the exact same
reason
> as the max(i++, j++) gives a wrong result.)

    also fixed by doing it in three stages, as above.

>   Using the template solution fixes all problems.
>

    Only if you have a compiler that allows you to use templates.

--
Pandora/Scott Hill/[::O:M:C::]Scorpion
Software Engineer.
http://www.pandora-software.com


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.