Csound Csound-dev Csound-tekno Search About

Serious bug causes compiler-dependent error

Date1999-11-25 08:35
FromGabriel Maldonado
SubjectSerious bug causes compiler-dependent error
Hi all,
I noticed that Intel-compiled ultra-fast version of DirectCsound
presents a bug due to the compiler parsing.
This bug is evident in sliderXX opcodes.

the reason is that the code:

   **result++ = value * (*max++ - *min) + *min++;   /* scales the output */


produces a different behaviour different from the two lines:

   **result++ = value * (*max++ - *min) + *min;   /* scales the output */
   min++;

While in MSVC both the two examples are parsed correctly, the Intel
compiler produces a wrong result in the first example, the correct one being
the second. So it is not possible to include the same variable in the
same instruction twice, when the second occurrence of that variable is
incremented. Please modify standard version to accomplish this drawback.
Maybe there are other occurrences of this technique in other parts 
of Csound code, so it is necessary to investigate.

-- 
Gabriel Maldonado

http://web.tiscalinet.it/G-Maldonado

Date1999-11-25 11:06
FromThomas Neuhaus
SubjectRe: [Csnd] Serious bug causes compiler-dependent error
On Thu, 25 Nov 1999, Gabriel Maldonado wrote:

> Hi all,
> I noticed that Intel-compiled ultra-fast version of DirectCsound
> presents a bug due to the compiler parsing.
> This bug is evident in sliderXX opcodes.
> 
> the reason is that the code:
> 
>    **result++ = value * (*max++ - *min) + *min++;   /* scales the output */
> 
> 
> produces a different behaviour different from the two lines:
> 
>    **result++ = value * (*max++ - *min) + *min;   /* scales the output */
>    min++;
> 

Sorry, but this is more your fault than INTEl's. 

The C-standard explicetely quotes, that the order of
subexpression evaluation is completely undefined. (cf. eg. K&R Appendix
A.7) 
So, whatever compiler you use, the second version is correct C, whereas
the first is, at least, questionable.

(But its a nice example. I will use it in my C-courses :-) )


Regards,

Thomas
--
Thomas Neuhaus(neuhaus@folkwang.uni-essen.de) Phone (49)-201-4903-333
ICEM Institut fuer Computermusik und elektronische Medien
Folkwang-Hochschule Essen, Klemensborn 39, D-49239 Essen  
-------------------------------------------------------------------------------
UNIX _is_ user-friendly. It just knows who its friends are.




--