If I write a complex double constant -3.I (as opposed to 0-3.I), what is
it supposed to evaluate to?  This program:

  #include <stdio.h>

  int main(void)
  {
    const __complex double C1 = (-3.I);
    const __complex double C2 = (0-3.I);

    printf ("%f %f\n", __real__ C1, __imag__ (C1));
    printf ("%f %f\n", __real__ C2, __imag__ (C2));

    return 0;
  }

when compiled with gcc-4.1.2 (and mainline) yields:

        -0.000000 -3.000000
        0.000000 -3.000000

Note the sign difference in the real part.

When I compile it with g++-4.1.2, I get:

        compl.c: In function 'int main()':
        compl.c:5: error: wrong type argument to unary minus

Is this supposed to happen or is it a bug in complex number parsing?
(Sorry if this is a gcc-help question.)

                Thanks,
                --Kaveh

Reply via email to