ID Number: Q65645
6.00 6.00a 6.00ax | 6.00 6.00a
MS-DOS | OS/2
buglist6.00 buglist6.00a buglist6.00ax
Summary:
The following use of the ternary conditional operator (?) should
convert the integer 2 into a float to match the 3.00. However, because
the constant 1 is used instead of a variable, the conversion is never
done. Instead of 2.0 (float), 2 (integer) is passed to printf() and
instead of printing 2.000000, the program prints 0.000000.
More Information:
According to the ANSI Standard, if the second and third operands to a
conditional operator are arithmetic types, the usual arithmetic
conversions are performed to make them a common type. (See Section
3.3.15, Lines 6-10). In this case, they should both evaluate to
floats.
Microsoft has confirmed this to be a problem in C versions 6.0, 6.0a,
and 6.0ax and QuickC versions 2.5 and 2.51 (buglist2.50 and
buglist2.51). We are researching this problem and will post new
information here as it becomes available.
Sample Code
-----------
/* Compile options needed: none
*/
#include <stdio.h>
double x;
void main (void)
{
x= 5.5;
printf ("%f\n", 1?2:3.00);
}
Additional reference words: 6.00 6.00a 6.00ax s_quickc 2.50