POV-Ray : Newsgroups : povray.bugreports : unexpected evaluation of #if(...)? : Re: unexpected evaluation of #if(...)? Server Time
14 Mar 2025 08:03:51 EDT (-0400)
  Re: unexpected evaluation of #if(...)?  
From: Tor Olav Kristensen
Date: 7 Mar 2025 19:50:00
Message: <web.67cb935c29b385b7883a5b8389db30a9@news.povray.org>
"ingo" <nomail@nomail> wrote:
> The following line results in an negative subscript error when Z = 0:
>
> #if (Z > 0 & VoxelGrid[X][Y][Z-1] > 0)
>
> I expected the evaluation to terminate, with false, at Z > 0.
>
> Won't say it is a bug, it is just unexpected.

Hi Ingo

There's some relevant information here:

https://en.wikipedia.org/wiki/Short-circuit_evaluation

In order to program in a more robust and portable way, one should avoid such
constructs that may differ between languages.

I suggest that you split this up into nested #if statements.

--
Tor Olav
http://subcube.com
https://github.com/t-o-k


Post a reply to this message

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