Issue Details (XML | Word | Printable)

Key: PCC-414
Type: Bug Bug
Status: Resolved Resolved
Resolution: Fixed
Priority: Major Major
Assignee: Anders Magnusson
Reporter: Fred J. Tydeman
Votes: 0
Watchers: 0

If you were logged in you would be able to see more operations.

Unary - of complex not supported

Created: 31/Dec/12 05:16 AM   Updated: 06/Jun/14 10:19 AM
Component/s: C frontend
Affects Version/s: None
Fix Version/s: None

Environment: Intel x86/x87, Fedora Core Linux 16, pcc 2011/12/16

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

 All   Comments   Change History      Sort Order: Ascending order - Click to sort in descending order
Anders Magnusson added a comment - 30/Apr/14 04:57 PM
Support for unary minus added for complex numbers.

Fred J. Tydeman added a comment - 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

Anders Magnusson added a comment - 02/Jun/14 03:39 PM
Can I get the code snippet that fails?
It works with this code:

_Complex a,b;

a = -b;

Fred J. Tydeman added a comment - 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;

Anders Magnusson added a comment - 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.

Anders Magnusson added a comment - 06/Jun/14 10:19 AM
Works now. Needed a few additions for imaginary numbers.