<< Back to previous view

[PCC-414] Unary - of complex not supported Created: 31/Dec/12  Updated: 06/Jun/14

Status: Resolved
Project: pcc
Component/s: C frontend
Affects Version/s: None
Fix Version/s: None

Type: Bug Priority: Major
Reporter: Fred J. Tydeman Assignee: Anders Magnusson
Resolution: Fixed Votes: 0
Environment: Intel x86/x87, Fedora Core Linux 16, pcc 2011/12/16

Unary negate of a complex variable gets a Not supported error message.

Comment by Anders Magnusson [ 30/Apr/14 04:57 PM ]
Support for unary minus added for complex numbers.
Comment by Fred J. Tydeman [ 02/Jun/14 03:34 PM ]
This is still broken in the 2014/04/20 build.
I am now testing on an Intel Core 2 Duo in 64-bit mode.
The OS is Linux Fedora Core 20.
This is pcc 1.1.0-0.1
Comment by Anders Magnusson [ 02/Jun/14 03:39 PM ]
Can I get the code snippet that fails?
It works with this code:

_Complex a,b;

a = -b;
Comment by Fred J. Tydeman [ 02/Jun/14 07:43 PM ]
Here is code that fails. The command line option I am using is: -g

#include <complex.h>
static long double complex ldc2;
int main(void){
  int rc;
  long double complex ldc1;
  ldc1 = - ldc2;

  if( (-(_Complex_I)) == (-_Complex_I) ){
    rc = 0;
    rc = 1;
  return rc;

Aside: Your code of _Complex a,b; is not valid C99 code. It needs to be one of:
 float _Complex a,b;
 double _Complex a,b;
 long double _Complex a,b;
Comment by Anders Magnusson [ 06/Jun/14 09:32 AM ]
It's actually unary minus of imaginary numbers that fails, not complex:
The Fedora headers define _Complex_I as 1.0iF, which is an imaginary number.
If _Complex_I is defined as 0+1.0iF it works with pcc.

This is due to gcc do not support handing of imaginary numbers, so the glibc people have been lazy.
Comment by Anders Magnusson [ 06/Jun/14 10:19 AM ]
Works now. Needed a few additions for imaginary numbers.
Generated at Thu Mar 30 08:54:12 CEST 2017 using JIRA Enterprise Edition, Version: 3.13.1-#333.